What determines the order of Ethereum transfer packaging? Understanding random numbers

Every time a transaction is sent to the Ethereum address, the nonce of the transaction will increase by 1. The transaction with a high nonce value will wait for the transaction with a low nonce value to complete first.

Original title: “The “Mysterious” Value of Deciding the Order of Transfers: Nonce”
Written by: Daisy

In “Ru Lin Wai Shi” there is a miser who is called Yan Jiansheng. He lies on the bed before his death and raises two fingers. The nephew at home and the nurse asked him if there was any wish, but they didn’t understand it. In the end, Yan Jiansheng’s wife, Zhao, guessed the reason. The lamp in the house was lit by two stems of grass. Yan Jiansheng felt too wasted and he refused to breathe. When Zhao took the stem from the lamp in the lamp, Yan Jiansheng kicked his legs, closed his eyes, and reassured himself.


Suppose that after years of reincarnation, Yan Jiansheng became a cryptocurrency investor in 2017. On this day, he used imToken 1.0 to transfer 10 USDT to Zhao’s family, but he still did not change his stingy nature and set the handling fee to be very low, but this transaction did not show a successful transfer after a long time.

Yan Jiansheng was a little anxious, and sent another 10 USDT transfers to Zhao. This time, he gave some extra fees, and he succeeded quickly, but the first transaction originally initiated failed.

Emmmm~ Why is this?


Recently, the miner fees for Ethereum network transfer are becoming more and more expensive, because we are in “Why are the miner fees so expensive?” “ Explained, so in the face of expensive miners’ fees, most people will choose to lower the miners’ fees. After all, it is not bad to be frugal.

However, when we use imToken 1.0 for transfer and adjust the transaction fee to a very low level, the above situation may occur: the first transaction is not packaged slowly, and after the second transaction is successfully initiated again, the first transaction is Will show failure.

The reason is caused by a value called nonce.

Every transaction that occurs on Ethereum has a value called nonce, which is used to calculate the number of transactions sent out in an Ethereum address. All transfers in an Ethereum address will sort each transaction according to the time you initiated the transfer, counting from 0. Each time the address sends a transaction, the nonce of the transaction will increase by 1, and the transaction transferred to this address will not change the nonce value.

for example:


As of the writing of this address, a total of 4 outbound transfers and 2 incoming receipts were initiated. Among them, the two transactions marked in the red box are not included in the nonce value calculation of the address, and the remaining 4 outbound transfer transactions The nonce values ​​are 0, 1, 2, 3 from bottom to top.


The Ethereum blockchain makes these three rules for nonce:

  1. Miners need to package and transfer according to the nonce value from small to large, so before the transaction with nonce 0 is not packaged by the miner, the transaction with nonce 1, 2, 3 ·· No matter how high the miner fee is, you must always queue up. (It’s like we can’t stop in the morning rush hour, no matter whether it’s Las Reis or Chery, we can only line up honestly).
  2. The nonce is continuous and cannot be skipped. When a transaction with a nonce of 1 is not initiated, a nonce cannot jump directly from 0 to 2, that is, a transaction with a nonce of 2 can only occur after a transaction with a nonce of 1.
  3. If there are two transactions with the same nonce, after one of the transactions is successful, the other transaction will appear to be replaced, and the transfer fails.

When Yan Jiansheng used imToken 1.0 to transfer money, the first transaction with nonce being 0, because the handling fee was too low, was not packaged by the miners in time and was always in a waiting state. At this time the nonce value of the second transaction he initiated again, guess whether it is 0 or 1?

The answer is 0.

You may be a bit puzzled. Didn’t you say that the nonce value will be +1 with every outgoing transfer from the address? How come the nonce value of both transfers is 0?

The reason is that imToken 1.0 does not support the initiation of continuous transfers. If the first transaction is not successfully packaged, the next transaction will be sent continuously, and one of the transactions will definitely fail. This is because the two transactions use The same nonce value.

According to the third rule of Ethereum nonce, when two transactions with the same nonce value occur, only one transaction can be successfully packaged. Similarly, when the first transaction is not successfully transferred, the nonce value of the second, third, and nth transactions initiated subsequently are all 0, and only one transaction can be successfully packaged by the miner. All other transactions will show failure. So, which transaction can be successful, is there any judgment standard?

For transactions with the same Nonce value, the one with the highest handling fee for the miners is more likely to succeed. This is not a stipulation of the Ethereum blockchain, but the miners are pursuing profits. Who doesn’t want to make more money? Of course, the miner will choose the transaction with more transaction fees to package, and other transactions with the same nonce will be discarded by the miner, which is displayed as a failure status in your wallet software.

These n transactions were launched one after another with the same nonce value. It is like an athlete with a different starting line but the same finish line. Only the first flying man Bolt can be followed by the public, and the others are unknown.


The upgraded imToken 2.0 supports the initiation of continuous transfers. If Yan Jiansheng uses imToken 2.0 to transfer, his first transaction nonce value is 0, and the second transaction nonce value is 1, even if the previous transaction has not been After packaging, the nonce value of the subsequent transactions will be automatically incremented by 1.

We mentioned above that when a transaction with a nonce of 0 is not packaged by a miner, a transaction with a nonce of 1 has to wait, so although the nonce value of subsequent transactions can be accumulated, it must be queued for the transaction with a smaller nonce value to be packaged Only then can it be your turn.

These n transactions are initiated one after another, and the nonce value keeps accumulating, just like athletes with different starting lines and different finish lines, but they must wait until the athletes on the first runway reach the finish line, and the athletes on the second, third, n… Before they can start.

If the person on the first runway is Bolt, then the subsequent few transactions can also be played soon, but if the person on the first runway is SpongeBob’s pet, the small snail, then the athletes behind the runway may have to Wait until the sky is old. At this time, you should give a small snail an energy bar to increase speed!


imToken 2.0 introduces an acceleration function for transactions with slow arrivals. This function is like an energy bar. After eating, the transaction can be quickly packaged by miners. imToken will automatically help you calculate the most cost-effective miner’s fee based on the network situation on Ethereum. Click “Accelerate Transaction” to complete the accelerated package of transactions.


The principle of “accelerated transactions” is actually very simple, that is, to initiate another transfer with the same nonce value but higher miner fees to cover the original. This transaction will be packaged faster, and the original transfer will be replaced.

If you are not sure how to set the miner’s fee for your own transfer, is it expensive or cheap? Don’t worry, the latest version of imToken already supports three-speed transmission, “fast, normal, slow” three kinds of transaction packaging speed, you choose.


imToken 1.0 does not support transaction acceleration and consecutively initiate multiple transactions. When the miner fee set for a transaction is too low, it will lead to delays in being packaged and unable to accelerate. And if the first transaction has not been successfully packaged, eager to initiate the second transaction will cause one of the transactions to fail.

imToken 2.0 supports transaction acceleration, three-speed transmission and multiple transactions initiated in succession. When the miner fee set in a transaction is too low, the miner fee can be added to speed up the package confirmation. In the latest version of imToken, you can choose the miner’s fee as needed, and the “three gears” can be seen at a glance; if you don’t mind the packing time, you can continuously initiate multiple transactions and wait for the transaction to be packaged and confirmed.

Leave a Reply
Related Posts

Bitcoin community outraged at SEC rule change

Key Facts: The commission will pay more to those who file useful complaints to hunt down “offenders”. The cryptocurrency industry requires clear rules for operating in the United States. The U.S. Securities and Exchange Commission, commonly known as the SEC, remains focused…
Read More