Wrong nonce number in eth_getTransactionCount

Hello everybody :slight_smile:

We’re facing an issue invoking the eth_getTransactionCount method.

Precisely, it seems that invoking the API using “pending” as default block parameter, we get unexpected results.
Moreover, invoking the same API multiple times in a short period of time the result change (and we expect that it remain the same because no transaction has been submitted in the meanwhile).

Following some CURL submitted, each one with the related response.

curl https://rinkeby.infura.io/v3/XYZ -X POST -H "Content-Type: application/json" -d '{onCount","params": ["0xe3d8ac14f047e200dfaec7b05fea8702554e1032","pending"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x123f"}

curl https://rinkeby.infura.io/v3/XYZ -X POST -H "Content-Type: application/json" -d '{onCount","params": ["0xe3d8ac14f047e200dfaec7b05fea8702554e1032","pending"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x11ba"}

curl https://rinkeby.infura.io/v3/XYZ -X POST -H "Content-Type: application/json" -d '{onCount","params": ["0xe3d8ac14f047e200dfaec7b05fea8702554e1032","pending"],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"0x1240"}

Note: There aren’t pending transactions, so we are expecting zero.

Any help or suggestion is really appreciated.

Thank you!

eth_getTransactionCount: get the number of current Tx.

In rinkeby you have transactions, so you will get that number.

If you spect 0 because you are seeing 0 Tx, maybe you are seeing the mainet or another network.

If you spect 0 because you put the “pending” flag. That means you will get the number of tx considering the pendings as well. The proper way to get the pendings is make a consult like:

#pendingsTx = pendings - latest

Note: If you send a Tx to another node and call the pendigs count of Infura maybe you will get a wrong answer because the Tx is not propagated, you must wait the propagation. The best way is push it to the same node or get a personal counter.

1 Like