Ethereum

Ethereum

eth_getTransactionCount

eth_getTransactionCount returns how many transactions an address has sent on Ethereum mainnet (chain ID 1, the network whose gas is paid in ETH) up to a given block — which is exactly the account's nonce. Every transaction from an account carries a nonce that must increase by one each time, and Ethereum uses it to order an account's transactions and to block replays. So the count this returns is also the next nonce you'll sign with. The block argument matters: at latest you get the nonce from confirmed transactions, while pending folds in what's already sitting in the mempool. Send the request to https://ethereum.therpc.io/YOUR_API_KEY.

Use cases

  • Grab the next nonce before signing: read at pending, use that value, and your transaction slots in right after whatever's already queued.
  • Spot a stuck transaction by comparing the two tags — when pending sits above latest, something you sent hasn't been mined and is holding up everything behind it.
  • Fire off a batch back-to-back by reading the nonce once, then incrementing it locally for each signed transaction instead of re-querying between sends.
  • Trace an account's lifetime activity by reading its nonce at historical heights, which needs an archive node to reach state that a full node has pruned.

Parameters

#NameTypeRequiredDescription
1addressstring (hex)YesThe account whose nonce to query.
2blockTagstringNoUse "pending" to include mempool transactions when chaining multiple sends.Default: latest

Response

TypeDescription
string (hex)Hex-encoded nonce (number of confirmed transactions sent from the address at that block).

Example request

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"latest"
],
"id": 1
}'

Try it live in the Ethereum playground.

Errors & troubleshooting

CodeMessageCause
-32602Invalid paramsAddress is malformed or block tag is unrecognised.
-32000Missing trie nodeHistorical block pruned on a non-archive node.

Common pitfalls

  • When sending several transactions in quick succession, read at pending, not latest. latest only counts confirmed transactions, so it hands the same nonce to every send in the burst and they collide.
  • Leaving a nonce gap stalls the queue. Submit nonce N+1 before N lands and the node parks N+1 indefinitely — Ethereum requires nonces to be used in strict sequence, so nothing after the gap can execute.
  • A contract account's nonce counts CREATE/CREATE2 deployments it makes, not ordinary calls into it. So a contract that never deploys another contract keeps a nonce of zero no matter how often it's invoked.

Supported networks

  • Mainnet — Chain ID: 1
  • Sepolia — Chain ID: 11155111

See also

Parameters

0x-prefixed 20-byte address

hex block number or "latest"/"earliest"/"pending"/"safe"/"finalized"

curl https://ethereum.therpc.io/YOUR_API_KEY \
-X POST \
-H 'Content-Type: application/json' \
-d '{"jsonrpc":"2.0","id":1,"method":"eth_getTransactionCount","params":["0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",""]}'

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.