← notes

The nonce is not the transaction count

May 30, 2023

Extract bits of onchain information about Base from the shell.

One script, total_transactions_for_address/main.sh, and it records a naming trap worth keeping. It calls eth_getTransactionCount, which does not return the number of transactions involving an address. It returns the account nonce, which counts only what that address has sent. Inbound transactions are not counted, and for a contract account it counts contracts created rather than calls received.

Everyone reading the method name gets this wrong at least once, and the reason it survives is that the value looks plausible. Nothing errors. You get an integer, it is the wrong integer, and analytics built on it propagate the mistake quietly.

The nonce is right for the thing it exists for, which is constructing a transaction, and wrong for describing activity. There is no single RPC call that answers the real question, that needs an explorer index or a log scan, which is why aiwa and base-indexer exist at all. Block tags are the smaller version: pending and latest give different nonces.

The general habit worth keeping is that when a method name and its return value do not obviously match, the name is describing an internal concept.