Bitcoin deep dive | Part 3 — Transactions

Mark Vaykhansky
3 min readMar 7, 2022

In the previous article in the series we’ve covered that blockchain is an append only, chronological and verifiable database. We explained that Bitcoin is a digital ledger stored on a blockchain. In this article we will learn about transactions. Transactions are the content of blocks on the Bitcoin blockchain.

Transactions Explained Via Example

How does a transaction really look?

Say Alice wants to interact with Bob on the Bitcoin blockchain and their current corresponding balances are 5 BTC and 3 BTC (BTC is short for Bitcoin). Alice wants to send one of her five BTCs to Bob. How might such transaction look? A trivial solution would be:

Alice → 1 BTC → Bob

There are a few problems with this proposition. First of all, there are many people named Bob and Alice. There is nothing that identifies the particular Alice and Bob mentioned above. To solve this problem each participant on the Bitcoin blockchain has a unique Bitcoin address. The Bitcoin address is derived from the public key of the public and private key pair each participant holds.

The Bitcoin address is derived from the public key via a cryptographic hash function (and a few other tricks) hence it is also unique.

So Alice and Bob have their unique Bitcoin addresses, address1 and address2, which uniquely identify them on the blockchain and now the transaction looks like this:

address1 → 1 BTC → address2

Transactions and addresses are public so in theory a third participant, Charlie, could add another transaction to the blockchain which looks like this:

address1 → 1 BTC → charlies_address

To prevent that, Alice has to sign the transaction with her private key, denoted pk.

DigitalSignature(address1 → 1 BTC → address2, pk)

That is better but what about a “replay”? Bob could simply create more transactions like this a transfer all of Alice’s BTCs to himself. To prevent that there is some unique id added to the message that is being signed in each transaction so:

DigitalSignature((address1 → 1 BTC → address2) + transaction_id, pk)

The last problems is that Alice doesn’t necessarily have 1 BTC in her disposal to spend. We need a way to verify Alice’s balance of BTCs and summing up all the transactions together will give us just that. If the balance is greater than 1 BTC then it is a valid transaction.

Transactions And The Blockchain

A few hypothetical blocks on the Bitcoin blockchain

Each block on the Bitcoin blockchain stores transactions. Each transaction is signed by the sender and is validated before being added to the chain. If there is an invalid transaction it can be easily spotted by an invalid balance or an invalid signature which would invalidate the block’s hash.

Take Home Message

Each participant on the blockchain has public and private key pair. The pubic key is used to validate the participant’s transactions and to create their Bitcoin address.

Transactions are the contents of blocks on the blockchain and they can be validate using a sender’s public key and their total balance that can be calculated by reading the entire blockchain of transactions.

The next article will be about the distributed nature of the Bitcoin blockchain, miners and proof of work.

--

--

Mark Vaykhansky

I'm a Software Engineer passionate about technology and leadership