Nonce in Cryptography: Ensuring Unique Transactions

Nonce is an arbitrary number, intended to be used only once; it is generated when the transaction is hashed by the miner.

What is nonce?

Nonce (literal meaning for once) is a method of sequencing and separating transactions on the Ethereum blockchain and other smart contract platforms. In cryptography, it is used as a non-repeating number to protect communications. An Ethereum wallet can transmit multiple transactions from an account to the network without significant latency between them. Therefore, a mechanism is needed to determine which transaction is processed first. Otherwise there will be failures caused by conflicting transactions related to account balance transfers.

If the transaction being translated has a nonce 2 value, it must be processed first before the transaction with a nonce 3 value. The underlying Ethereum network is designed so that a transaction with a higher nonce value cannot be included in any block until the transactions preceding it have been cleared and settled on the network.

In this process, however, problems can arise because if a transaction with a lower nonce value gets stuck (due to gas volume), then all transactions received after that with a higher nonce value will also get stuck.

The process of undoing and speeding up transactions on the Ethereum network is also based on nonce. If a user wants to cancel a transaction, he can send to his own wallet a transaction with the same nonce number as the transaction he is trying to cancel. But this is not always guaranteed, because if the nonce is the same, any transaction can be approved at random.

In the case where a transaction is stuck and not approved, users can raise the gas price and send the same transaction with the same nonce number. Since the nonce number remains the same and the fee has been increased, the probability of that transaction being approved is higher. In some wallets, both of these functions are automated.

Related terms