Bitcoin transaction: how does it work?

In the previous article we had a quick introduction to the blockchain technology. In this article we are going to see what’s happening behind a bitcoin transaction.

Let’s take a simple example: Robert and his friends went to the Bit&Beer pub where bitcoin payments are accepted. After the whole night of drinking and having fun it’s time to pay the bill!
The waiter takes out a smartphone and shows the QR code to Robert for the payment of the bill. Robert takes out his smartphone as well, opens his bitcon app, scans the QR code, checks if the payment details are correct and presses the PAY button.

The QR code is a kind of a bar code but more complex, it contains several types of information, like:

  • the ewallet of the receiver (in our case Bit&Beer)
  • bitcoin amount to transfer
  • general information (like the name of the receiver)

When Robert presses the PAY button he creates a new transaction which contains the sender’s ewallet (Robert) and the receiver’s ewallet (Bit&Beer) details, the amount of bitcoins and a small fee. The fee however is not mandatory: the sender can decide whether or not to include the fee (transactions with a higher fee have a higher priority).

What is happening behind the scene?

The transaction is propagated in the bitcoin network (phase #1 of the scheme); the waiter of Bit&Beer can see Robert’s payment on his phone almost instantly, the status however is NOT CONFIRMED.

Who decides whether a transaction is valid or not?

The transaction is considered valid when special nodes in the network (called Miner) will append this transaction into a block in the blockchain.
This process is called Mining (phase #2 of the chart) and it has the following purposes:

  • to validate the transaction (referring to consensus protocol) or to reject an invalid transaction.
  • to create new bitcoins.

The process of Mining is the essential phase where the transactions are stored in the blockchain. In this step the transaction is being included inside a new block and this block is appended to the blockchain.
It is not simple at all to create a new block. Mining a block requires complex operations using a lot of computational power; this operation is called proof-of-work and it verifies the data on the blockchain and makes it immutable.

Miners are racing with each other to create a block: the first one that creates a block which satisfies the requirements earns some bitcoins and the fee within the transactions (phase #3 of the chart).

A new block is propagated on the network (phase #4 of the chart); other miners which received a new block, are going to check if the block is valid first and then include the new block in the blockchain.
Finally, the waiter of Bit&Beer can see in his ewallet that the payment has been confirmed. All this process is about 10 minutes long _

This is the English translation of a post that I wrote for comprarebitcoin.com

Related Articles

How a blockchain works - the Proof of Work

Category: Blockchain

When we were talking about mining, we mentioned a difficult puzzle that a miner has to solve. What is this puzzle and what is it for? Before reading this article, I suggest you read these two ...

What is the mining? Who is the miner?

Category: Blockchain

The mining is the process where the data is collected in a block and then the block is appended to the blockchain. This process is done by the miner. Before digging into the process of mining, ...

What is a fork? Why is it dangerous?

Category: Blockchain

Often a blockchain can have some flaws, bugs or it just needs improvements. To fix those vulnerabilities the blockchain has to be forked. A fork rewrites the rules which a full node must follow in ...

How a blockchain works... Let's make one!

Category: Blockchain

Have you ever wondered why the blocks on the blockchain are stored one after another? In this article we are going to talk about the basic blockchain concepts; these concepts will be fundamental ...

Blockchain for dummies!

Category: Blockchain

This article is one of several articles in which I explain in a very simple way what a blockchain is. What is the difference between Bitcoin and Blockchain? Blockchain is the technology behind ...

Blockchain For Not Technical People (public speech)

Category: Blockchain

A 4 minutes speech about blockchain I delivered during a course on public speaking in November 2019.