๐ฆ Understanding the UTXO Model โ
The foundation of how Ergo handles value and state
What is UTXO? โ
UTXO stands for Unspent Transaction Output. It's a fundamentally different way of tracking balances compared to account-based blockchains like Ethereum.
The Cash Analogy โ
Think of UTXOs like physical cash:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โ ๐ต Your Wallet Contains: โ
โ โ
โ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โ
โ โ $20 โ โ $10 โ โ $5 โ โ
โ โ bill โ โ bill โ โ bill โ โ
โ โโโโโโโโโโ โโโโโโโโโโ โโโโโโโโโโ โ
โ โ
โ Total Balance: $35 โ
โ But it's in 3 separate "UTXOs" (bills) โ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโSpending UTXOs โ
When you make a payment, you:
- Select bills (UTXOs) that cover the amount
- Consume those bills entirely
- Create new bills for recipient and change
mermaid
graph LR
subgraph "Your Wallet"
A[$20 bill]
B[$10 bill]
end
subgraph "Transaction"
C[Consume $20 + $10]
end
subgraph "Results"
D[$25 to Merchant]
E[$5 Change to You]
end
A --> C
B --> C
C --> D
C --> EKey Differences from Account Model โ
| Aspect | UTXO (Ergo, Bitcoin) | Account (Ethereum) |
|---|---|---|
| Balance | Sum of all UTXOs | Single number |
| Spending | Consume entire UTXO | Subtract from balance |
| Parallelism | High (independent UTXOs) | Low (single state) |
| Privacy | Better (new outputs each tx) | Worse (same address) |
| Complexity | More complex | Simpler |
UTXO in Code โ
typescript
// An account model might look like:
const account = { balance: 100 };
account.balance -= 30; // Send 30
// UTXO model is different:
const utxos = [
{ value: 50n, id: "box1" },
{ value: 50n, id: "box2" }
];
// To send 30, you must:
// 1. Select input(s) that cover 30
// 2. Create output for recipient (30)
// 3. Create change output for yourself (50 - 30 - fee = ~19)
// 4. The original UTXO is destroyedBenefits of UTXO โ
1. Parallel Processing โ
Each UTXO is independent, so multiple transactions can be processed simultaneously:
User A spends UTXO #1 โโโโโโโโโโโบ Transaction A
User B spends UTXO #2 โโโโโโโโโโโบ Transaction B
โ
Both process in parallel!2. Enhanced Privacy โ
New addresses/UTXOs for each transaction make tracking harder:
Tx 1: Address A โ Address B (new)
Tx 2: Address B โ Address C (new)
Tx 3: Address C โ Address D (new)3. Simpler Verification โ
Each UTXO can only be spent once - no need to track global state.
Extended UTXO (eUTXO) โ
Ergo uses Extended UTXO, which adds:
- Registers (R0-R9): Store arbitrary data
- Scripts: Complex spending conditions
- Tokens: Native asset support
typescript
// Standard UTXO (Bitcoin):
{
value: 1000000,
scriptPubKey: "..."
}
// Extended UTXO (Ergo):
{
value: 1000000000n,
ergoTree: "...", // Spending script
assets: [ // Native tokens
{ tokenId: "...", amount: 100n }
],
additionalRegisters: { // Custom data
R4: "0e...",
R5: "0e..."
}
}Next Steps โ
- Box Structure โ - Deep dive into Ergo boxes
- ErgoScript Basics โ - Writing spending conditions
- First Transaction Tutorial โ - Build your first tx