Now that you’ve set up your bitcoin wallet and are ready to make your first transaction, let’s take a look at how bitcoin transactions actually work.
There are three key variables in any bitcoin transaction: an amount, an input and an output. An input is the address from which the money is sent, and an output is the address that receives the funds. Since a wallet can contain several input addresses, you can send money from one or more inputs to one or more outputs. There is also a data storage portion on each transaction, a sort of note, that allows you to record data to the blockchain immutably.
But the unique thing about bitcoin transactions is that, if you initiate a transaction that’s worth less than the total amount in your input, you get your change back not to your original output, but through a new third address in your control. This means your wallet typically ends up containing multiple addresses, and you can pull funds from these addresses to make future transactions.
You’ve learned how to buy and store your bitcoins, so you already know what public and private keys are for, and you’ll need these to issue a transaction. To do that, you put your private key, the amount of bitcoins you want to send and the output address into the bitcoin software on your computer or smartphone.
Then the program generates a signature made from your private key to announce this transaction to the network for validation. The network needs to confirm that you own the bitcoin being transferred and that you haven’t spent it by checking all previous transactions which are public on the ledger. Once the bitcoin program verifies that indeed your private key corresponds to the provided public key (without knowing what your private key is), your transaction is confirmed.
This transaction is now included in a “block” which gets attached to the previous block to be added to the blockchain. Every transaction in the blockchain is tied to a unique identifier called a transaction hash (txid), which looks like a 64-character string of random letters and numbers. You can track a particular transaction by typing this txid in the search bar on the blockchain explorer.
Transactions can’t be undone or tampered with, because it would mean re-doing all the blocks that came after. This process is not instantaneous. Because the bitcoin blockchain is fairly large, it takes a lot of time to process a single transaction among the many on the blockchain.
The amount of time it takes to confirm a transaction varies, ranging anywhere from a few minutes to a couple days, based on traffic on the blockchain and the size of your transaction. Larger transactions with higher fees tend to get validated by miners quicker than smaller ones. That said, once it is confirmed, it is immutably recorded forever.