UTXO vs Account Model
Bitcoin uses the “UTXO Model” meanwhile Ethereum uses the “Account Model”.
UTXO Model (like Bitcoin)
A UTXO represents a certain amount of cryptocurrency that has been sent to a user but has not yet been spent. In simpler terms, think of a UTXO as a digital equivalent of a cash bill. Just like you can use a bill to make a purchase, you can use a UTXO to participate in a new transaction.
Each UTXO is indivisible, meaning you either spend it entirely or not at all.
How the UTXO Model Works in a Transaction
When a transaction occurs, it consumes one or more UTXOs and generates new UTXOs as outputs. Here’s a step-by-step breakdown of the process:
- Inputs: The sender uses their existing UTXOs as inputs to the transaction. Each input must reference a previous UTXO.
- Outputs: The transaction then creates new UTXOs as outputs. These outputs are assigned to the recipient's addresses and can be spent in future transactions.
Example Transaction
Suppose Alice wants to send 3 BTC to Bob. She has two UTXOs, one worth 2 BTC and another worth 2 BTC. In this example, the inputs total 4 BTC, the output to Bob is 3 BTC, and the change output to Alice is 1 BTC.
Here’s how the transaction would look:
- Input: Alice uses her two UTXOs (2 BTC + 2 BTC) as inputs.
- Output: The transaction generates two outputs:
- 3 BTC to Bob
- 1 BTC as the change back to Alice
Get started with Bitcoin operations at the following link.
Account Model (like Ethereum)
The account-based model in blockchain is analogous to a bank's ledger system. It maintains a global state of accounts, each identified by a unique address, with associated balances and other states. There are two types of accounts in Ethereum:
- Externally Owned Accounts (EOAs): Controlled by private keys and used by individuals.
- Contract Accounts: Controlled by code (smart contracts) and can execute code when receiving a transaction.
How the Account Model Works in a Transaction
In the account-based model, transactions directly modify the account balances and states. Here’s a step-by-step breakdown of the process:
- Account Balances: Each account has a balance representing the amount of cryptocurrency (e.g., Ether) it holds.
- Transactions: When a transaction occurs, it specifies a sender and a recipient. The sender’s balance decreases by the transaction amount (plus any fees), and the recipient’s balance increases by the transaction amount.
- Smart Contracts: Transactions can also trigger smart contracts, which are programs that run on the blockchain. These contracts can change state, interact with other contracts, and even create new transactions.
Example Transaction
Suppose Alice wants to send 3 ETH to Bob. Here’s how the transaction would look:
- Sender: Alice’s account.
- Recipient: Bob’s account.
- Transaction Details:
- Alice’s balance decreases by 3 ETH (plus a small transaction fee).
- Bob’s balance increases by 3 ETH.
Updated 2 months ago