Zondax signet

Looking for a hardware wallet app? Go to HubZondax.ch

Beryx
NEW

Solutions

Contact us

UTXO vs Account Based Blockchain

May 27, 2022


During the first four years after the launch of Bitcoin, we used to have only one kind of model for accounting: Unspent Transactions Output. It also defined what a transaction is composed of inputs and outputs.

Then the change occurred. In 2013, Vitalik Buterin proposed the idea of what was going to become Ethereum - the account-based model was created. Vitalik wanted to build Ethereum on top of Bitcoin, but this significant difference in conception made it impossible.

In this post, Zondax's engineer will explore the two models and examine their advantages and trade-offs.

UTXOs model

image.jpeg

Unspent Transactions Outputs is the collection of yet to be used outputs. The combination of those outputs allows us to determine the total amount available. It is a digital representation of how coins would exist. Your total balance is the total of coins you still have in your hands (so that you haven't used yet) with the big difference that we can cut a coin into several pieces and that they would exist as several other smaller coins and not destroyed.

Transactions are composed of outputs and inputs; an input is a previous output, and once a previous output is declared in an input, it is considered spent and cannot be spent again.

To clarify this, let's examine a transaction:

Input:

Previous tx: f5d8ee39a430901c91a5917b9f2dc19d6d1a0e9cea205b009ca73dd04470b9a6

Index: 0

scriptSig: 304502206e21798a42fae0e854281abd38bacd1aeed3ee3738d9e1446618c4571d1090db022100e2ac980643b0b82c0e88ffdfec6b64e3e6ba35e7ba5fdd7d5d6cc8d25c6b241501

Output:

Value: 5000000000

scriptPubKey: OP_DUP OP_HASH160 404371705fa9bd789a2fcd52d2c580b65d35549dOP_EQUALVERIFY OP_CHECKSIG

The input indicates that we take the transaction f5d8…b9a6 and look at the output at the index 0 (because a transaction can have several outputs). This is this previous tx. We notice that the value of this previous output is 50BTC. Great! That's the exact amount we are spending in our output.

For a transaction to be valid, the total of inputs values - the total of outputs values > 0. The difference is what we call fees. They are not explicitly given to anyone, allowing the miner to attribute them to itself once he mines the block in a special kind of transaction : coinbase transaction. Fees are also not required in a transaction. However, today 0 fee transactions will unlikely be relayed by nodes to avoid spam.

Bitcoin's concept is to be an electronic cash software, so it tried to replicate coins' design. However, while physically, coins make sense, it is more challenging to picture once dematerialized.

Account model

Ethereum was the first project to implement the account model. In a UTXO-based transaction, we noticed that we don't have a To field, which Ethereum introduced.

Ethereum maintains a global state, and each account has an associated amount of ether. A transaction modified this state, and we have a new one.

image.jpeg

An Ethereum transaction has the following fields:

  • Nonce - A transaction nonce to keep the order of the transactions
  • GasPrice - The price per unit of gas
  • Gas - The amount of maximum gas you are willing to paid
  • To - The destination address
  • Value - The amount
  • Data - Extra data like function called in a contract (for a simple transfert is null)
  • V - The 1 byte recovery id (to help recover the From address)
  • R - the R value of the ECDSA signature
  • S - The S value of the ECDSA signature
  • In Ethereum the order of the transactions matters. Each contract has a state and the order might have changes that produce different states with different orders. We also need to keep in mind that we are in an asynchronous network and that transactions might not arrive to a server in the same order they were sent. It is why we are required to associate an account nonce to each transaction. It is important to track the number of transactions or the nonce can be queried to a synced node.

    Another important difference is that the fees are explicitly mentioned. Ethereum being a “world computer” its language is Turing-complete. Therefore it is confronted to the Halting Problem. Indeed it is impossible to tell if a program is going to stop unless we run it. To avoid falling in an infinite loop Ethereum have to stipulate when to stop. In case of an infinite loop it would be impossible to get the new state.

    It is possible that a transaction is in the chain but actually failed. Transactions that run out of gas before finality will lose their gas to pay for the miner computing time. Contracts being stateful it makes it difficult to calculate fees.

    Conclusion


    Bitcoin and Ethereum are inherently different in the way they define transactions because of their different accounting models. Ethereum has a more bank-like approach that depends on knowing the global state of the chain because of its Turing-complete contract feature.

    Bitcoin was shaped by its ambition to become an electronic cash system.

    Both of those projects have shaped today's blockchain landscape.

    Read More Articles

    Protocol

    Apr 15, 2024

    Filecoin Upgrade v22: Dragon

    Lotus v1.26.2 introduces the Filecoin upgrade v22, Dragon, enhancing ecosystem efficiency and security. It adds Direct Data Onboarding and Actor events, setting new blockchain standards.


    General
    [email protected]

    Solutions

    Security

    Company

    We're Hiring!

    Legal