Lessons 1/4 · 20 min
UTXO or accounts: one transfer
A matter of cash
Think of your wallet. Either you hold notes and coins: to pay 60 you hand over a 50 note and a 20 note, and you get 10 in change. Or you hold a balance on a mobile-money account: to pay 60, the balance drops by 60. Blockchains made both choices.
- UTXO model (unspent transaction output). The state is a set of indivisible "outputs", each locked to an owner. Bitcoin works this way.
- Account model. The state is a table: for each account, a balance and a counter (the nonce, lesson 2). Ethereum, chains built with the Cosmos SDK and Substrate/Polkadot chains work this way.
The same transfer in both models (fictitious figures)
Awa owns 80 units and wants to pay 60 to Bineta, with 2 units of fee.
In UTXO. Awa owns two outputs: one of 50 and one of 30. Neither is enough alone, so the transaction consumes both as inputs (50 + 30 = 80) and creates new outputs:
| Amount | |
|---|---|
| Inputs (consumed outputs) | 50 + 30 = 80 |
| Output 1: to Bineta | 60 |
| Output 2: change back to Awa | 18 |
| Fee (inputs − outputs: 80 − 78) | 2 |
An output is never spent in part: it is consumed whole, and the change is a new output sent back to yourself. The fee is written nowhere: it is the difference between inputs and outputs. Once consumed, the 50 and 30 outputs disappear from the set.
In accounts. Awa's balance goes from 80 to 80 − 60 − 2 = 18. Bineta's rises by 60. In this simplified example, the 2 of fee go to the proposer. Awa's nonce increases by 1.
How each prevents double spending
- UTXO: an output can be consumed only once. A second transaction consuming it is invalid, because the output is no longer in the set.
- Accounts: the balance is checked at execution time, and the nonce imposes a strict order on an account's transactions (lesson 2).
An honest comparison
| UTXO | Accounts | |
|---|---|---|
| What the state holds | A set of unspent outputs | Balances and nonces, plus code/storage on contract chains |
| Fees | Implicit (inputs − outputs) | Explicit transaction fields |
| Error temptation | Forgetting the change output: the difference becomes fees | Sending transactions in the wrong nonce order |
| Complex contracts | Possible, but shared state is less natural | Natural: a contract is an account with code |
What this does NOT guarantee
- The UTXO model is not automatically "anonymous": reusing an address or merging inputs links outputs together.
- The account model is not "less secure": the nonce and the balance check play there the role that single-consumption plays in UTXO.
- Neither model protects against sending to the wrong address.
Recap
UTXO: consume whole outputs and create new ones; fee = inputs − outputs. Accounts: update balances; explicit fees; the nonce orders.
