Bitcoin Fundamentals: Step by step explanation of a peer-to-peer Bitcoin transaction

This Video shows a more technical explanation of what is Bitcoin and how does it work

Nakamoto introduced bitcoin on 31 October 2008 to a cryptography mailing list by publishing the White Paper “Bitcoin: A Peer-to-Peer Electronic Cash System[1][2], and released as open-source software in 2009.

Bitcoins are created as a reward in a competition in which users offer their computing power to verify and record bitcoin transactions into the blockchain. This activity is referred to as mining and successful miners are rewarded with transaction fees and newly created bitcoins.

Technically, Bitcoin consists of:

● A decentralized peer-to-peer network (the Bitcoin protocol)

● A public transaction ledger (the blockchain)

● A set of rules for independent transaction validation and currency issuance (consensus rules)

● A mechanism for reaching global decentralized consensus on the valid blockchain (Proof-of-Work algorithm)

One of the most interesting things is that blockchain promises disruptive changes because empowers the ‘Internet of Value’ that represents a world where money is exchanged at the speed in which information moves today. Transactions would occur in real-time and across global networks, solving the problem of international payments systems that are not interoperable. And what is more: as it does not need intermediaries, the concept goes further and in turn favours the social inclusion.

Here is a high-level example of a peer to peer transaction.

So, how does it work?

1. Nick opens his bitcoin wallet. This implies that Nick is indirectly creating his own bitcoin address. He’s supposed to get some bitcoins.

2. Nick wants to transfer bitcoins to Rose. So, he scans or copies Rose’s bitcoin address.

3. Nick fills an amount of bitcoin he wants to transfer and the fee he is willing to pay for this transaction. So, a transaction includes inputs, outputs and the amount of bitcoin that will be transferred.

4. Before sending the new transaction to the blockchain, the wallet using Nick’s private key signs it.

5. Now, the transaction is sent to the closest node on the bitcoin network. Then it is propagated into the network and verified (basic checks: eg. there are enough bitcoins on the origin wallet, structure, etc.). After it successfully passes verification it goes and sits inside the “Mempool” (short for Memory Pool) and patiently waits until a miner picks it up to include it in the next block to be mined.

6. It’s mining time and miners pick up the transactions (first those who pays more transaction fee) and group them into blocks trying to solve the Proof Of Work (or POW — a consensus algorithm) and calculate a certain hash function.

7. The miner who get it propagates the new block to the network.

8. The nodes verify the result and propagate the block.

9. Now Rose sees the first confirmation.

10. New confirmations appear with each new block that is created and linked.

The transaction in more detail:

A Bitcoin transaction is composed of 4 key elements:

  1. Input (Origin): Bitcoin address (public) of the origin wallet.
  2. Amount: Amount of bitcoins to be sent on the transaction.
  3. Output (Destination): Bitcoin address (public) of the destination wallet.
  4. Metadata (Optional): The metadata or message has a maximum size of 80 bytes. The metadata is stored in the OP_RETURN part of the transaction.
Bitcoin Transaction components

A transaction doesn’t simply move some bitcoin from one address to another address. A Bitcoin transaction moves bitcoins between one or more inputs and outputs. Each input is a transaction and address supplying bitcoins. Each output is an address receiving bitcoin, along with the amount of bitcoin going to that address.

A sample Bitcoin transaction. Transaction C spends .008 bitcoins from Transactions A and B.

The diagram above shows a sample transaction “C”. In this transaction, .005 BTC is taken from an address in Transaction A, and .003 BTC is taken from an address in Transaction B. For the outputs, .003 BTC are directed to the first address and .004 BTC are directed to the second address. The leftover .001 BTC goes to the miner of the block as a fee. Note that the .015 BTC in the other output of Transaction A is not spent in this transaction.

Each input used must be entirely spent in a transaction. If an address received 100 bitcoins in a transaction and you just want to spend 1 bitcoin, the transaction must spend all 100. The solution is to use a second output for change, which returns the 99 leftover bitcoins back to you.

Transactions can also include fees. If there are any bitcoins left over after adding up the inputs and subtracting the outputs, the remainder is a fee paid to the miner. The fee isn’t strictly required, but transactions without a fee will be a low priority for miners and may not be processed for days or maybe discarded entirely. A typical fee for a transaction is 0.0002 bitcoins (about 20 cents), so fees are low but not trivial.

So how does it work?

Step 1: Bob and Alice create the transaction

STEP 1: Transaction creation and signing

Anyone can create a transaction with 3 necessary components. The Input, Amount and Output. For example, let´s say that Bob and Alice are exchanging bitcoin for dollars. As Bob sends the bitcoin to Alice, Alice needs to send her bitcoin address (public) and Bob creates the transaction and sign it with his private key.

STEP 2: Bitcoin transaction broadcasting

STEP 2: Broadcasting

Once the transaction is created, it is sent to the closest node on the bitcoin network. Note: The transaction doesn´t need to be sent right after the creation. It could be sent a long time after the creation (just need to be sure that you have enough bitcoins in the wallet when you decide to send it)

Step 3: Propagation and verification

STEP 3: Propagation and verification

Once the transaction arrives at the closest node, then it is propagated into the network and verified. After it successfully passes verification it goes and sits inside the “Mempool” (short for Memory Pool) and patiently waits until a miner picks it up to include it in the next block.

Step 4: Block Validation

STEP 4: Validation

Once the transaction is on the Mempool, then the miners pick up the transactions (First those who pays more transaction fee) and group them in blocks. As on May 2017, each block has a maximum size limit of 1 MB (change in this limit is under discussion by the community) and contains around 2.000 to 3000 transactions, depending on the size of each transaction. Then, by using the Proof-of-Work Consensus Algorithm, the network agrees on the valid block, and consequently the transactions, on average every 10 minutes.

Follow me on Twitter!

[1] “What is the Bitcoin Mempool? — 99Bitcoins.” 1 May. 2016, https://99bitcoins.com/what-is-bitcoin-mempool/.

[2] “Bitcoin: A Peer-to-Peer Electronic Cash System.” https://bitcoin.org/bitcoin.pdf. Accessed 5 May.

[3] “CoinMarketCap.” https://coinmarketcap.com/.

Emerging Technology Enthusiast | Digital Asset Management | Quantitative Strategy | Financial Markets