Blockchain – Ethereum Nonce vs Bitcoin Nonce

In the previous blog we discussed what a nonce is in the blockchain and successfully mining a block requires a minor to be the first to guess the nonce, which is a random string of numbers .The nonce exists in both the Ethereum and Bitcoin protocols, but in Ethereum there are two types of nonce

  1. A block Nonce
  2. Transaction Nonce

As mentioned in the previous blog post, in Bitcoin only a block nonce is used. You will recall that this demonstrates proof of work consensus algorithm for a block. Therefore the nonce is just an arbitrary value used to manipulate the hash of the block. Currently Ethereum uses this same nonce and hashing strategy for proof of work. This could change in time if / when Ethereum moves over to proof of stake consensus algorithm.

A transaction nonce is an unrelated value used in the Ethereum protocol to prevent transaction replays.

It’s important to be aware that Bitcoin is a UTXO (Unspent Transaction Output) based protocol, and Ethereum is an account based protocol. Therefore when coins are spent in Bitcoin, the coins themselves ( represented as UTXO’s) are signed over to another address .

So say for example, I received a payment of 10 BTC, I’d have a UTXO record for 10 BTC. It would be written to the blockchain that this 10 BTC UTXO record belongs to my address, and that my private key is the only key that can sign a transaction spending it.

If I sent 3 of those coins to you, I’d create a transaction which would take my 10 BTC UTXO as input, and produce two outputs, a 3 BTC UTXO for you, and another fresh 7 BTC UTXO for me. It would be recorded to the blockchain that we both had rights to the resulting 3 and 7 BTC UTXOs. The original 10 BTC UTXO would no longer exist, since it was spent in the transaction.

A UTXO can only be spent once in a single transaction. It is always replaced by the outputs of that transaction.

In Ethereum, the blockchain stores balances associated with accounts instead of unspent transaction outputs. So therefore you can’t double spend with different nonce’s nor can you double spend with the same nonce in Ethereum.