When a transaction is hashed by a miner, an arbitrary number meant to be used only once is generated, called a nonce.

What Is a Nonce?

Nonce (literal meaning — for one occasion) is a way to sequence and segregate transactions on the Ethereum blockchain and other smart contract platforms. Generally, it is used in cryptography as a non-repeated number for securing communication. An Ethereum wallet can broadcast multiple transactions from an account, without much delay between one another, to the mainnet. Hence, it is necessary to have a mechanism which can determine which transaction is processed first. Otherwise, there would be malfunctions caused by conflicting transactions associated with account balance transfers.

For example, if a broadcasted transaction has a nonce value of 2, it must be processed first before the transaction with nonce value of 3. The Ethereum mainnet is designed in such a manner that a higher-nonce-value transaction couldn’t be included in any blocks until the ones before them are cleared and settled on-chain. 

However, this process can have issues since if a transaction with a lower nonce value is stuck (owing to the gas amount), all transactions received afterwards with nonce values higher would also be stuck.

The process of transaction cancellation and transaction speeding on the Ethereum network also uses “nonce” as its basis. For instance, if a user wishes to cancel a transaction, he can send a transaction to his own wallet with the same nonce number as the transaction he is attempting to cancel. It’s not always guaranteed, though, since if the nonce is the same, any transaction might get randomly approved. In case a transaction is stuck and does not get approved, users can raise the gas price and send the same transaction with the same nonce number. Since the nonce number is the same while the fee has been bumped, this transaction has a higher probability of being validated. Some wallets have both of these functions automated.