Blockchain Account Models: Accounting vs UTXO Models
Tags: blockchain, web3, ethereum
Published: 2022-05-15 04:31:25

The blockchain is a very complex database that records ownership and transfer of ownership. Technically, we could say the purpose of the blockchain is to record past transactions and events, kind of like a [state machine](https://developer.mozilla.org/en-US/docs/Glossary/State_machine). A state machine in the sense that, the blockchain can remember previous transactions that have happened on it, and then create a new state from these transactions. The transactions are broadcast to the network, a consensus is reached, and a block is added with a permanently recorded state. These different transactions continuously happen on the blockchain and require very careful tracking to maintain the reliability and integrity of the underlying blockchain.

There are fundamentally two major accounting models in the blockchain space, so it’s usually one or the other, but it’s important to understand how they work and what makes them different. Most blockchains use either the Balance/Account model or the UTXO (Unspent Transactions Output) model. We will discuss the attributes of the two models and also compare them both. 


Prerequisites

To follow along with this article, a basic understanding and familiarity with blockchain concepts are required. This is not a technical article so no knowledge of coding is required.


Account/Balance Based Model

We’ve referred to the blockchain as a state machine. In a balance model, the state of the blockchain is represented in terms of accounts and balances. This is very similar to how traditional banks work where the user has an account with an account number and a balance. When you need to send money, the account remains the same and only the balance gets reduced. When your balance hits 0, you cannot send any money out. In terms of blockchain, the account would be a wallet address, and the public key is the account number. The balance is the quantity of the token you have. A very popular blockchain that uses this model is the Ethereum blockchain, most blockchains generally use this model.


STATE TRANSITION IN ACCOUNT-BASED MODEL

In an account-based model, the user creates a wallet with a public key that can be used to make transactions and a private key for signing transactions. This wallet holds all the tokens available to the user. An example is the Ethereum blockchain as mentioned earlier. Ethereum uses an account-based model and that means, the user’s wallet holds all their available ether as a whole value. Even though I say ether, the wallet also holds all [non-fungible tokens](https://ethereum.org/en/nft/). This is similar to how traditional banks manage value. Say Nico has $1000 in her bank account and needs to transfer $100 to Sanji, the bank deducts 100 from Nico's 1000 and now, Sanji has $100 more while Nico has $900 left in her bank account. This is the same as how Ethereum manages the state. The state, in this case, would be the amount of ether you have in your wallet or any tokens (fungible or non-fungible). 

To be able to validate a transaction in an account-based model, the validator needs to know about the entire state of all wallets that are involved in the transaction. To create a transaction on Ethereum, you need to provide the wallet, which will contain a lot of data.


Unspent Transaction Outputs, UTXOs

The second type of accounting model is the UTXO model. This is a powerful and yet less employed model. Unlike the account model, the UTXO model does not incorporate accounts or wallets at the protocol level. This model is based on individual transactions, grouped into blocks. This can be easily compared to holding a certain amount of cash. Consider, a user can have $2000, but it could, in reality, be a combination of $100 bills, $50 bills, and so on. Similarly, a user cannot just have 100BTC, it’s usually in multiple UTXOs. The bitcoin blockchain is a good example of a UTXO-based blockchain.

A transaction output must be spent as a whole in a particular transaction. For example, say Alice has a UTXO holding 0.5BTC and wants to send 0.3BTC to James. Then Alice has to create a transaction with her UTXO as input and then return two UTXOs, one for her 0.2BTC change, and the other will be James’ 0.3BTC. Using our money example, If Alice wants to give James $60 from her $100 note, then she has to release the $100 note to James and expect James to give her her change of $40.

A UTXO is never this balanced, there are always fees that have to be paid for every transaction so, in the above example, Alice might have 0.18BTC after paying the fees. A crucial note is that, for a UTXO, the task of collecting change is on the creator of the transaction. While building your transaction, the transaction builder has to specify which address the change from the transaction gets sent to.

A more advanced type of UTXO model is the [E-UTXO (Extended UTXO) model](https://docs.cardano.org/plutus/eutxo-explainer) that Cardano blockchain employs. This adds an extra layer of information to the transaction in the form of Datums for attaching special properties of data to the UTXO and also a redeemer for interacting with the UTXO via a smart contract. It makes the UTXO model more flexible and also allows more data to be attached to the UTXO.


STATE TRANSITION IN A UTXO MODEL

In a UTXO, every transaction that happens on the network creates a new state. The only thing that makes a difference between similar transactions is the transaction fees. For every transaction that happens in a UTXO model, we don’t need to send a lot of data like the account model. We only need the input UTXOs, a Pubkey Script (which defines the spending condition), and the data needed to satisfy the script is provided also along with the necessary signature.

In our Alice-James example where Alice with a single UTXO of 0.5BTC wants to send 0.3BTC to James, she will need to create a transaction with all of her 0.5BTC as transaction input. For a UTXO to be spent, it needs to be unlocked and the condition for spending/unlocking is specified in the pubkey Script, this can also be a smart contract. Next, Alice herself defines what she intends to do with her UTXO. She specifies a new UTXO for James’ 0.3BTC and another for herself, to keep her change. The difference between the value of the output UTXOs is the fee Alice paid for her transaction.


DIFFERENCES BETWEEN ACCOUNT-BASED AND UTXO-BASED MODEL

We will compare some important differences between a UTXO and an Account Model. This is not to say one is better than the other, but of course, they both have strengths and weaknesses. There are a few key aspects that can be compared for both models such as; computational view, scalability, privacy, smart contract capability, and more. There’s a lot to say about these comparisons, but we will talk about a few of them. 
As a prelude, it is important to note a key detail in the way the two operate. The UTXO model is a verification model, because users build transactions, sign them and submit them to create new UTXOs. The job of the nodes is then to verify that the consumed inputs are truly unspent and that the signature(s) satisfy the spending conditions. An account-based model, on the other hand, is a computational model. Users submit transactions telling the nodes what the new state transition should look like and the networks then compute the new state based on the instruction.

When it comes to the size of the blockchain. The account model has efficient memory usage. It consumes less memory to save a single account balance than to save multiple chunks of UTXOs that make up a user’s balance. In an account model, the transaction specifies the sender, receiver, the amount (value) to transfer, and a digital signature. A UTXO can consume more than one input, several inputs may need to be combined to form a single or several outputs and the blockchain needs to save these making it heavier than an account-based model.

For privacy, the UTXO model is more private. When multiple UTXOs are involved, it makes tracking down harder and if there is a change address involved, it can be different from all the addresses involved in the transaction adding an extra layer of privacy compared to an account model where the account data as a whole is available, it’s easy to get data on transactions of an account.


CONCLUSION

Summarily, we talked about balancing models in the blockchain. We discussed the unique features of an account-based model versus a UTXO-based model and saw what makes them both special and useful. We talked about examples of both models as well. We can agree that the blockchain is a state machine and see why the need for a proper accounting model is dire. 

In the UTXO model, the movement of assets or values is like a directed acrylic graph made of transaction outputs where new outputs are added as unspent and old outputs are spent making them unusable anymore. In an account model, balances are stored as a global state of accounts, kept by the node, and updated with every block. Very similar to what a database is.

UTXO transactions are larger because they have to consider more data, more inputs, pubkey script, and signatures but this makes it harder to track who performed what transactions and therefore offers a lot more privacy. The account model on the other hand only stores the global state of the blockchain and therefore requires less memory on the blockchain but this makes it easy to track all transactions of a specific account. Not so much of a privacy issue, but could be a potential privacy blocker.