Skip to content

๐Ÿ“ฆ 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:

  1. Select bills (UTXOs) that cover the amount
  2. Consume those bills entirely
  3. 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 --> E

Key Differences from Account Model โ€‹

AspectUTXO (Ergo, Bitcoin)Account (Ethereum)
BalanceSum of all UTXOsSingle number
SpendingConsume entire UTXOSubtract from balance
ParallelismHigh (independent UTXOs)Low (single state)
PrivacyBetter (new outputs each tx)Worse (same address)
ComplexityMore complexSimpler

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 destroyed

Benefits 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 โ€‹

Released under the MIT License.