Bitcoin is digital money and to understand how transactions work with Bitcoin—how a wallet is debited and credited—you need to have an idea of how transactions work in the traditional system.
To send money to someone's bank account, you'll need:
Behind the scenes, a program is set up to prevent you from sending more than you have or using the same money for two transactions (double spending).
When sending Bitcoin to someone,
Three major concepts define this process:
The amount of bitcoin remaining after a transaction is executed can be used as input in future transactions. Technically, it is called UTXO - Unspent Transaction Outputs, a function programmed to prevent fraudulent transactions on the Bitcoin blockchain.
UTXO has two major components:
Let's recap. To send bitcoin:
This entire process is recorded on the Bitcoin blockchain, creating a permanent record of the transaction.
The Bitcoin white paper shows that Satoshi aimed to solve the problem of double spending, common in the banking system. Fraudulent activities can be easily perpetrated if one can use only $100 in their account to pay for groceries and for Uber, both costing $100 each. The UTXO framework simply ensures that you can't spend the same coin in more than one transaction or spend more than you own and that's why the coins are marked with serial numbers (given references).
In the Bitcoin network, nodes (the computers that keep the system running) only need to track the current receipts (UTXOs) rather than the entire transaction history. This makes it easier and more efficient to grow and manage the network as more people use it.
In a centralized system, implementing the described state transition would be straightforward. A centralized server could keep track of Bitcoin’s record on its hard drive, handle all the transactions, and update accordingly. This approach relies on trust in a central authority to manage the data accurately and securely.
But in times when the server is down, people will not be able to make transactions with Bitcoin. Such a single point of failure is one of the reasons why Bitcoin exists- to share control and also ensure constant operation of the blockchain.
As a crypto newbie, you've probably heard of the consensus mechanism. It is simply a method of agreement used to validate transactions on any cryptocurrency. In this regard, computers (nodes) make the agreement.
Bitcoin nodes follow this process to check if a transaction should be either approved or rejected:
Each transaction in a Bitcoin block must ensure a valid transition from the current state (before the transaction) to a new state (after the transaction).
A transaction must correctly change the current valid state to a new state. For example, if Amber has $100 and sends $50 to Jaden, Amber should have $50 left, not $100. The states are not stored in any of the blocks to save storage space but are tracked by validating nodes—computers participating in approving transactions.
The state of any block is determined by starting from the initial state and applying every transaction in order up to the current block, ensuring all nodes calculate the same state.
Example
Amber has 10 BTC.
To determine the current state:
When determining states, it's important to start from the initial state. If nodes start at different points in the middle, they will get varying results. The goal is to achieve the same result across all nodes, ensuring transparency.
Creating blocks in Bitcoin is intentionally difficult to prevent attacks where a single node tries to take over the blockchain for personal gain. This is why the proof-of-work system exists. Think of it as a puzzle where the first person to get the correct answer is rewarded for their proof of work (pun intended!).
Each block in the blockchain contains data, including transactions and a reference to the previous block.
The data is run through a 'unique fingerprint' or hash (SHA256) twice.
The result obtained is a very long string of numbers and letters, often represented in hexadecimal format like this: 00000000000000000007d0f084a5e4c1fbc0fdb451d0d7a5b2f2ac1245e8d938
The Bitcoin network sets a dynamically changing number called the target.
For a block to be valid, its double-SHA256 hash must be numerically smaller than the target.
Miners actively work to find the numerical figure that matches by solving really hard puzzles.