Sign in

The account model

Suggest an edit

Bitcoin tracks money as discrete coins that get consumed and recreated. Ethereum tracks money as account balances that get modified in place. This change cascades into everything else: how transactions look, what state means, how contracts hold funds, why nonces exist.

A program needs a place to keep its data

Bitcoin's state, as the lesson on the UTXO model showed, is the set of currently unspent outputs, each locked to an address by a script. A set of locked coins has nowhere for a program's data to live between transactions.

Ethereum uses a different model called the account model. Instead of tracking individual coins, the chain tracks accounts. Each account has an address, a balance of ETH, and possibly some additional state. For a contract, that additional state is storage: key-value pairs that persist across calls, which the contract's code reads and writes as transactions come in. Each account has its own slice of storage that the protocol tracks, so a contract can have a million users with a million different balances stored in it. This is hard to express in UTXOs.

What an Ethereum account contains

An account on Ethereum has four fields:

  • A balance of ETH, stored as an integer in wei, where one ETH is 10^18 wei
  • A nonce, which is a counter that increases by one with every transaction the account sends
  • A code hash, which is empty for regular user accounts and points to the deployed bytecode for contract accounts
  • A storage root, which is empty for regular user accounts and points to the contract's storage tree for contract accounts

Two kinds of accounts exist. Externally owned accounts, or EOAs, are controlled by a private key. Their code hash and storage root are empty. They behave like a Bitcoin address: you sign transactions with the matching key to spend their balance or trigger something else on the chain. Contract accounts are controlled by code. They have a balance like any other account, but they also have code that runs when called and storage that persists between calls. They have no private key, so nobody can sign transactions from a contract account. The only way to move a contract's funds or change its state is to call its code from another account, and the code decides what happens.

The chain's state at any moment is the combined state of every account that exists: balances, nonces, and, for contract accounts, code and storage. When a block is produced, every full node applies the block's transactions to this state, computes the new state, and rejects the block if its claimed result doesn't match.

A payment changes two balances in place

In Bitcoin, if Alice has a single 10 BTC UTXO and wants to send 3 BTC to Bob, her transaction consumes that UTXO and creates two new ones: 3 BTC locked to Bob's address, and 7 BTC locked back to one of her own addresses as change. In Ethereum, if Alice has a balance of 10 ETH and wants to send 3 ETH to Bob, her transaction just says: send 3 ETH to Bob. After the transaction, her balance is 7 and Bob's balance has increased by 3. Nothing gets consumed or created, so there is no change output.

Bitcoin UTXO model vs Ethereum account model for Alice's payment to BobOn the left, Bitcoin's UTXO model spends Alice's 10 BTC UTXO and creates two new UTXOs: 3 BTC for Bob and 7 BTC change back to Alice. On the right, Ethereum's account model just updates balances in place, from Alice 10 ETH and Bob 0 ETH before, to Alice 7 ETH and Bob 3 ETH after. UTXO model (Bitcoin) Account model (Ethereum) Before Alice's UTXO 10 BTC Before Alice: 10 ETH Bob: 0 ETH Transaction Alice sends 3 BTC to Bob input: Alice's 10 BTC UTXO output: 3 BTC to Bob output: 7 BTC back to Alice Transaction Alice sends 3 ETH to Bob from: Alice to: Bob value: 3 ETH After Bob's UTXO 3 BTC (new) Alice's UTXO 7 BTC (new, change) After Alice: 7 ETH Bob: 3 ETH (balances updated in place) Same payment. Completely different state representation.

Reading state gets simpler, parallelism and privacy get worse

State changes are simpler to reason about. In Bitcoin, "what is Alice's balance" requires scanning the entire UTXO set for outputs locked to her addresses and summing them. In Ethereum, "what is Alice's balance" is one lookup in the state table. This makes contract code simpler. A token contract just keeps a mapping from address to balance and updates it on every transfer. The protocol doesn't need to know what the contract is doing, because the contract manages its own state.

Parallelism is harder. Two Bitcoin transactions that touch different UTXOs are independent and can be processed in parallel. Two Ethereum transactions that touch the same account may conflict. The Ethereum protocol processes transactions sequentially within a block to handle this. Most newer chains, including Solana, build elaborate machinery to recover the parallelism Ethereum gave up.

One address links a whole history. Every transaction an account sends is tied to the same address, so anyone who knows that the address is Alice's can read everything she has done with it. In the UTXO model Alice can keep her coins under many addresses, and the chain has no permanent identifier that ties them to her.

The nonce stops a signed transaction from being replayed

Recall the nonce from the account fields. It starts at zero, and Alice includes her current value in every transaction she signs. The chain only accepts the transaction if the nonce matches what it expects from Alice's account.

The nonce exists because the account model has a problem the UTXO model doesn't. In Bitcoin, a transaction is uniquely identified by the UTXOs it consumes. If Alice broadcasts the same transaction twice, the second one fails because the first one already consumed the input. Replay is impossible by construction.

In Ethereum, a transaction is "send 3 ETH from Alice to Bob." If someone rebroadcasts that same signed transaction, the network needs a way to tell it's the same one, and the nonce gives it one. The first transaction Alice sends has nonce 0. If the network sees a second transaction from Alice with nonce 0, it rejects it as a duplicate. Alice's next transaction must use nonce 1, the one after that nonce 2, and so on.

The nonce also enforces ordering. If Alice broadcasts transactions with nonces 5, 6, and 7, the network will include them in that order regardless of when they arrive. Transaction 6 can't be processed until transaction 5 is in a block. This matters for contracts that depend on a specific sequence of calls. The nonce is also how a pending transaction gets replaced: Alice sends a new transaction with the same nonce and a higher fee, and whoever produces the next block takes the one that pays more.

Ask what stops a signed message from being used twice

Whenever a signed message moves value, ask what stops the same signed message from being submitted again. For a transaction, the protocol answers with the account's nonce. When your own contract accepts signatures, as in gasless approvals, the contract has to keep that counter itself.