UTXO and Account-Based Blockchains

UTXO and Account-Based Blockchains

Blockchain Knowledge

Crypto APIs Team

Apr 7, 2022 • 5 min

Unspent transaction output (UTXO) and account-based are two types of record-keeping methods used by a blockchain network to record provenance of its cryptocurrency and how cryptocurrency balances are determined. 

Bitcoin and many Bitcoin derivatives such as Bitcoin Cash, Zcash, Litecoin, Dogecoin, Dash, and more are UTXO chains. While Ethereum, EOS, Tron, and Ethereum Classic are account-based chains.  

To the general user, buying and trading in BTC or ETH may appear pretty similar, but the way the blockchains perform transactions is quite different. 

In this article, we will explore what are these models and the differences between them. 

What Is a UTXO Chain?  

A UTXO chain is a blockchain using the unspent transaction output accounting method. UTXO is the original form of cryptocurrency blockchain first introduced in the Bitcoin whitepaper by Satoshi Nakamoto, the mysterious creator(s) of the premier cryptocurrency.  

In a UTXO based ledger, there are no accounts or wallets* - at least not at the protocol layer.  

Instead, transactions are composed of a series of inputs and outputs, and the coins are stored as a list of unspent transaction outputs (UTXOs).    

*Wallets can be created on UTXO based blockchains like Bitcoin using Crypto APIs, but these are not on the chain’s protocol level.  

How Do UTXOs Work? 

Transactions on a UTXO chain are created by using existing UTXOs and creating new UTXOs in their place. A UTXO value can’t be divided but it can be combined with other UTXOs to meet the required amount of a transaction.  

The easiest way to explain how this model works is to think of UTXOs as cash bills. Just like a paper bill can’t be divided, a UTXO value has to be consumed as a whole.  

For example, let’s say you have a $10, $20, and a $50 bill.    

Purchase Scenario #1  

You want to purchase an item that costs $10.  You use the $10 bill.  This results in one transaction input of the $10 bill and one transaction output (recipient gets a $10 bill).   

Purchase Scenario #2  

The item costs $30. You use $10 and $20. In this case, you have multiple inputs and just one output with the recipient getting $30.   

Purchase Scenario #3  

The item costs $55. You pay using the $10 and the $50 bills, totaling $60.  The recipient takes $55 and gives you $5 back. There are multiple inputs (the two bills of $10 and $50) and multiple outputs— the $55 received and the $5 you now have in change.   

The bills you spend and receive back (outputs) will be used to make future payments, at which point they will become inputs. Until then, they are classed as unspent, ie. Unspent Transaction Outputs (UTXO).  

How Does This Look On the Blockchain? 

Say you want to send someone 3.75 BTC, but only have a UTXO worth 10 BTC in your wallet. In this case you have to send the entire UTXO to the recipient and receive change. Just like you would when paying in cash.  

Of course, this process is handled by the blockchain protocol, and doesn't require you to trust the recipient to return your change.  

So, when you made this transfer, the recipient receives their 3.75 BTC, and the remaining 6.25 in "change" would be sent back to your address as a new, smaller UTXO. 

What Is an Account-based Chain?   

Account-based blockchains tend to be smart contract focused, such as Ethereum, EOS, Tron, and Ethereum Classic. The account-based model is a balance management system that works in a similar way to the traditional bank account.  

Unlike UTXOs, value in an account-based balance can be partially spent. For example, if you have 100 ETH, you can send someone 37.5 ETH directly from your account. The result of this transaction is that you now have 62.5 ETH and the other person has 37.5 ETH. There’s no need to send the full 100 ETH and receive 62.5 ETH in change, as you would on a UTXO chain.   

Instead, when a transaction is requested on the account-based chain, it triggers nodes to withdraw the exact amount from the balance of the sender’s account and deposit it to the balance of the receiver’s account.   

The account-based model is more efficient, as each transaction only needs to be checked to show that the sending account has enough balance to pay for the transaction.   

Tracking Blockchain Transactions and Balances  

When building dApps such as crypto wallets or exchanges, developers need to include a way to calculate how much cryptocurrency is in a balance for both UTXO and account-based chains. For the UTXO model especially, this can be a challenge as you need to keep track of all the UTXOs for every single transaction.  

Using a blockchain infrastructure provider can help you get this job done easily. Crypto APIs has created a set of unified endpoints that simplify the process for both UTXO chains and account-based chains, as well as for all types of digital wallets, including HD Wallets.  

With our List Wallet Transactions API endpoint customers can list transactions to and from their wallet on Bitcoin, Bitcoin Cash, Litecoin, Ethereum, Ethereum Classic, and more. The data this endpoint returns includes transaction Id, direction of the transaction - incoming or outgoing, the amount and more. 

Crypto APIs also provides the same support for HD Wallets for UTXO based chainsList HD Wallet (xPub, yPub, zPub) UTXOs and List HD Wallet (xPub, yPub, zPub) Transactions are two really useful endpoints, since HD wallets have a lot of addresses and transactions and pulling the data on-demand is a heavy operation.   

List HD Wallet UTXOs provides quick and easy access to HD Wallet data by providing the extended public key of the already synced HD Wallet.  

The results returned by the API endpoint can include the public address, the UTXO amount value, whether the UTXO has been used from another unconfirmed transaction, whether the transaction is confirmed or unconfirmed, and the transaction ID. 

Check out our technical documentation for more Crypto APIs endpoints and learn how we can support your blockchain or crypto project.  

Related articles