2 min read

A transaction exists as a record of the transfer of bitcoin. All transactions are recorded in blocks on the blockchain. Most users use wallets to send and receive Bitcoin transactions. Wallets do all of the technical work in the background so that users can simply specify an address and an amount to send to that address.

Learn more about Bitcoin transactions.

When a transaction is ready, it is broadcast to nodes on the Bitcoin network. These nodes keep the transaction in a pool of pending transactions called the mempool until miners add it to a block. Only once a transaction is added to a block is it confirmed. It is a safe practice to wait until a transaction has been in the blockchain for at least 6 blocks to consider it settled with finality.

Under the hood, a transaction consists of three main parts: inputs, outputs, and a signature. Inputs are simply pieces of bitcoin called UTXOs which the payer chooses to spend. Outputs send a specified amount of bitcoin to a specified address, creating a new UTXO. A transaction can contain any number of inputs and outputs. Lastly, in order for the transaction to be valid, the payer must sign the transaction, thereby proving ownership of the inputs they are attempting to spend. This signature is produced using the payer’s private keys.

Learn more about digital signatures.

Let’s walk through an example transaction: Alice owns a UTXO worth 1 BTC and wishes to pay Bob 0.4 BTC. Thus, she uses the 1 BTC UTXO as an input. In order to send Bob exactly 0.4 BTC, Alice creates two outputs: the first to Bob, in the amount of 0.4 BTC, and the second back to herself, in the amount 0.59 BTC. This means that she paid a 0.01 BTC transaction fee.

Key Fact: the fee of a Bitcoin transaction is not an output of the transaction.
The fee is not itself an output. It is implied by the sum of the inputs (1 BTC) minus the sum of the outputs (0.4 + 0.59 = 0.99 BTC) and is collected by the miner.

Lastly, Alice uses the private key controlling the 1 BTC UTXO to sign the transaction before broadcasting it to the network. When this transaction is added to the blockchain, the 1 BTC UTXO will be destroyed, and two new UTXOs in the amounts of 0.4 BTC and 0.59 BTC will be created, belonging to Bob and Alice respectively.