How to deal with abnormal transaction Pending on Ethereum

Transaction Pending

Reasons for ETH transaction pending:

  • 1. The transaction GasPrice is set too low, and the consensus node does not package

  • 2. The account Nonce is not continuous and has been in the queue of the transaction pool

As long as the cause is confirmed, a corresponding solution can be made.

GasPrice is set too low

Since the ETH consensus node packages transactions according to the Gas price from high to low, if the GasPrice of each transaction is set too low, it will always wait for the transaction with the high price to be packaged first, while the transaction with the low price is in the Pending state.

The low price here has two meanings:

  • One is lower than the minimum GasPrice set by the consensus node
  • One is lower than the other deal.

For the first case, if the transaction is lower than the minimum GasPrice of the consensus node, the transaction will be rejected by the consensus node when it is broadcast from the full node to the consensus node, so that it cannot be packaged.

The second situation is that although the GasPrice of the transaction is greater than the minimum GasPrice of the consensus node, it is at a low level in the transaction to be executed, and it needs to wait until other high-price transactions are packaged before execution.

For the above two cases, it is only necessary to increase the GasPrice to replace the previous transaction.

Account Nonce is not continuous

In ETH, transactions submitted by the same account need to be executed in the order of Nonce. When the consensus node packages the transaction, it will also package the transaction according to the order of the account Nonce. If the Nonce is not continuous, then the subsequent transactions will be Pending.

We can query the Nonce needed next time through the NonceAt method in the SDK.

Guess you like

Origin blog.csdn.net/cljdsc/article/details/128957986