How Do Digital Currencies Work?

For a moment, let's consider the case where two individuals (peers) wish to make an exchange.  In this example, User X will send User Y 0.5 Bitcoins.  In the description below, important definitions are highlighted like this.  You can look them all up on the important definitions page.

Step 1:  Two users initiate a transaction between their wallets

Each user must already have the appropriate wallet software downloaded to their PC, and they must have already generated a public wallet address (also known as a public key).  User X goes into their wallet software, enters User Y's address (User Y's public key), enters the 0.5 Bitcoins they want to send, and presses the "Send" button.  Immediately 0.5 Bitcoins are removed from User X's wallet, and within a few minutes those same 0.5 Bitcoins are added to User Y's wallet.  But what happens behind the scenes?

Step 2:  A block of transactions is created

When she presses send, User X has initiated a transaction.  The transaction is digitally signed using User X's private key to generate an encrypted electronic signature, and then broadcast to the network.  The broadcast goes to other users around the world who run specialized wallets that are "full nodes"...i.e., they contain complete copies of the blockchain (a record of all transactions for all Bitcoins since the first coin generated).  These nodes condense the most recent transactions into a block which contains multiple transactions.  Once the full nodes have consensus on which transactions should be included in the current block (usually this is a democratic process of first submitted, first included although this process can be circumvented if the sender pays a transaction fee), the block is then sent to miners. 

Step 3: The block is mined

The miners then go about solving incredibly complicated math puzzles in an attempt to confirm that all of the transactions in the current block are valid (i.e., that the digital signature on each transaction in the block is valid meaning that the transaction is actually coming from the owner of the wallet, and that all of the sending users actually own the number of coins they are sending to their respective recipients).  This process does take some time (called the "block time", and for Bitcoin it is 10 minutes.)  Mining is an open process, and anyone can attempt to solve the mathematical puzzles.  Once these puzzles are solved, the block is considered solved.  The block is then ready to be added to the blockchain, the public ledger and the backbone of most digital currencies.

Step 4:  The newly mined block is added to the blockchain

In order to add a block to the blockchain, the miners then create what is called a hash (a digital fingerprint of sorts) of the last block added to the blockchain, and they include this hash in the current block and then add this newly modified block+hash combination to the blockchain ledger and broadcast it to the network.  Other miners take a brief moment to confirm that they see the newly added block on the ledger, and the process repeats.  When the new block is added to the blockchain, the miner who originally solved the block is provided a reward in the form of the digital currency in use (in this example Bitcoin) plus any transaction fees that may have been included to expedite transactions.

At the end of this process, User X is 0.5 Bitcoins poorer, User Y is 0.5 Bitcoins wealthier, and one lucky miner has earned himself or herself Bitcoins for solving the block.  Lather, rinse, repeat.