A bitcoin transaction is a signed piece of information for the purpose of transferring ownership of a set amount of bitcoins from one individual to another. The transaction records all the details of the sender’s unspent bitcoins, their origin (denoted by the transaction ID, or hash of the transaction), the transfer amount, and the public address of the receiver. It is broadcast to the Bitcoin network for validation, and, if it passes, it is then placed in an online ledger called the blockchain for transfer The validated transaction is added to a block of information, and this block is then linked to another block, creating a chain of blocks (hence, blockchain).
To get a better sense of how bitcoin transactions work, I have created illustrated and detailed guides which you will find below. I use names in the examples in order to make it easier to read, but one of the key advantages of bitcoin transactions is anonymity, so the parties are never privy to each-others personal information. In reality, all you need to complete a bitcoin transaction is the address of the sender and recipient.
The Input & Output of a Bitcoin Transaction
If Alex sends a payment of 1 bitcoin to Natalie, the transaction would look like this:
This is a simplified version of a bitcoin transaction, but we can add more information to get a bigger picture. For example, the source of Alex’s 1 bitcoin is a payment that he received from Andreas, from a previous transaction. What Alex received from Andreas is called the Input in the transaction, while Alex’s payment to Natalie is called the Output. The Input always indicates the source and the amount of bitcoins, whereas the Output specifies the destination and the amount of the bitcoins intended for the recipient, Natalie.
Knowing this, we can now illustrate the bitcoin transaction like this:
In our example, there is only one single Input and one single Output but a bitcoin transaction can contain multiple Inputs and Outputs. A bitcoin transaction has an Input and Output list, each with their own index or sequence number for every entry. The number zero (0) is always considered as the first entry.
Notice the modification of the Inputs and Outputs of the first transaction between Andreas and Alex. Andreas had 3 bitcoins, which he received as payment by a client in a previous transaction, and he had to send Alex the amount of 1 bitcoin. What’s fascinating about the Bitcoin protocol is that the cryptocurrency is not divisible. Meaning, in this case, Andreas can’t send just 1 bitcoin to Alex. What happens instead, is that Andreas sends all 3 of his bitcoins to Alex and then receives 2 bitcoins back as change.
Transactional Security
After receiving the bitcoin from Andreas, Alex has to prove that he is who he claims to be, before he sends the bitcoin to Natalie. In order to do this, Alex has to “solve” the Input Script with his private key. For more information on private keys, please refer to my Bitcoin Keys and Addresses article.
Once Alex does that, he can go ahead and spend the bitcoins in the Input. The cycle continues as Alex will have to create a script for Natalie to solve, in order for her to spend the payment she receives from him. Additional information – such as the version of the transaction, the lock time (i.e. the specified time for the transaction to be added to the blockchain), and any other specific rules that need to be followed – is part of the transaction details.
Finally, just as with every kind of financial transaction, there has to be some kind of identification. In the case of bitcoin, that comes in the form of a transaction ID.
Once the transaction has been created, it is then relayed to other nodes on the network for the verification process. The Bitcoin network nodes will, in turn, investigate the information of the proposed transaction for validation purposes. Is all the information there? Is the unspent number of bitcoins actually available and unspent? Are there any issues of double spending? Is the transaction signature valid?
If validated, then the transaction will be passed for conformation and added to a transaction block for the next step. This is the mining part, which is necessary in order for the transaction to end up in the blockchain, and something that I will cover in a future article.