What are Blockchain Record-keeping Models?
UTXO
model in Bitcoin Vs Account/Balance Model Ethereum
Two types of record-keeping
models are popular in todays blockchain networks. The first method is called
the UTXO (Unspent Transaction Output) Model and the second one is the
Account/Balance Model. The UTXO model is employed by Bitcoin, and Ethereum uses
the Account/Balance Model.
In UTXO, a users
wallet keeps track of a list of unspent transactions associated with all
addresses owned by the user, and the balance of the wallet is calculated as the
sum of those unspent transactions.
The Account/Balance
Model, on the other hand, keeps track of the balance of each account as a
global state. The balance of an account is checked to make sure it is larger than
or equal to the spending transaction amount.
There are two types of record-keeping
models in todays blockchain networks, the UTXO (Unspent
Transaction Output) Model and the Account-Based Model.
This is the original form of a blockchain
used by Bitcoin and many Bitcoin derivatives such as Bitcoin Cash, Zcash,
Litecoin, Doge, Dash, and more. In a UTXO based ledger, there are no accounts
or wallets* at the protocol layer. Instead, coins are stored as a list of
unspent transaction outputs or UTXOs. Each UTXO has a quantity and criteria for
spending it. Transactions are created by consuming existing UTXOs and producing
new UTXOs in their place. UTXO represents the output of a transaction received
by a user and the balance of an address is the sum of unspent
transactions(UTXOs).
The short answer is like cash.
Lets take an example where you have $100
in cash. There are number of different variations you might have:
Five $20 bills
Two $50 bills
Ten $10 bills
One $50 bill and five $10 bills
and so on
Despite having different combinations you
always have $100 exactly. This is how UTXOs work, when you see a balance of 1
Bitcoin in a crypto address, this can be combination of two UTXOs of 0.5
Bitcoin etc. from previous transactions. When we want to Bitcoin, we use one or
more existing UTXOs, enough to cover the cost and maybe receive some change
back (new UTXO). The concept of change in UTXOs is explained further.
Just like banknotes, UTXOs can not be
divided. Take an example where you want to buy a coffee and the coffee costs
$3.75. In your wallet, you have a $5 bill and you must overpay for the coffee,
but then $1.25 is returned to you as change.
Just like banknotes, you cant spend part of a UTXO. If you got UTXO of 5
Bitcoin in your address and you need to send someone 3.75 Bitcoin you need
again to overpay and 5 Bitcoin is sent as input to the transaction. You will
receive 1.25 Bitcoin as a new UTXO or change in an address owned by you.
To understand better UTXO based model you
need to know the differences between the banknotes and UTXOs.
In the example with the coffee, you will
get back $1.25 as change, which can be five quarters or one $1 bill and one
quarter etc., while with UTXO, change can come in any amount.
Transactions on the blockchain require
transaction fees, which is used to reward the miners, and transaction fees
would be deducted by the change you receive.
Blockchains that are using the
Account-based model are Ethereum, EOS, Tron, Ethereum classic etc.
Under the account-based model, unlike with
UTXOs, balances can be partially spent. For example, if you have 100 ETH, you
can send someone 37.5 ETH directly from your account, and the result of this
transaction is that you now have 62.5 ETH and the other person has 37.5 ETH.
You dont have to send the full 100 ETH and then receive 62.5 ETH in change, as
you would on a UTXO chain.
Account-based blockchains sometimes create
confusion among Crypto APIs users, because the result of a transaction depends on the input
state. Care must be taken when executing transactions in parallel. Generally,
transactions affecting the same account will need to be executed one after
another
Account-based Model is more efficient, as
each transaction only needs to validate that the sending account has enough
balance to pay for the transaction.
* Wallets can be created on UTXO based blockchains like Bitcoin using Crypto
APIs, but those are not on protocol level.