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
pendingsits abovelatest, 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
| # | Name | Type | Required | Description |
|---|---|---|---|---|
| 1 | address | string (hex) | Yes | The account whose nonce to query. |
| 2 | blockTag | string | No | Use "pending" to include mempool transactions when chaining multiple sends.Default: latest |
Response
| Type | Description |
|---|---|
| string (hex) | Hex-encoded nonce (number of confirmed transactions sent from the address at that block). |
Example request
Try it live in the Ethereum playground.
Errors & troubleshooting
| Code | Message | Cause |
|---|---|---|
-32602 | Invalid params | Address is malformed or block tag is unrecognised. |
-32000 | Missing trie node | Historical block pruned on a non-archive node. |
Common pitfalls
- When sending several transactions in quick succession, read at
pending, notlatest.latestonly 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/CREATE2deployments 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"