BNB Smart Chain

BNB Smart Chain

eth_getTransactionCount

Every outbound transaction on BNB Smart Chain must carry a strictly increasing nonce, and eth_getTransactionCount reports that nonce: the number of transactions an address has sent as of the block you specify. On a network that spends BNB for gas and finalizes blocks in roughly three seconds, getting the nonce right is what keeps your sends from colliding or stalling. Query https://bsc.therpc.io/YOUR_API_KEY on chain ID 56 with an address and a block tag, and the method hands back the count as a hex integer. That is typically the value you assign to the very next transaction you sign.

Use cases

  • Fetch the nonce that your next freshly built BSC transaction should carry before signing and broadcasting it.
  • Notice transactions wedged in the mempool by comparing the latest count against the pending count for one address.
  • Fire several transactions in a row by pre-assigning consecutive nonces instead of waiting for each to confirm.
  • Chart an account's activity across time by reading its nonce at a series of historical chain-56 blocks.

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://bsc.therpc.io/YOUR_API_KEY \
-X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x8894E0a0c962CB723c1976a4421c95949bE2D4E3",
"latest"
],
"id": 1
}'

Try it live in the BNB Smart Chain 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

  • For rapid back-to-back sends, request the pending tag. The latest tag keeps returning the same number until each transaction confirms, so you would reuse a nonce.
  • Leave a gap (submit nonce N+1 while N is still unmined) and every later transaction parks in the queue until the missing one arrives or is replaced.
  • A contract account's nonce ticks up only when it deploys another contract via CREATE, not on ordinary calls into or out of it.

Supported networks

  • Mainnet — Chain ID: 56
  • Testnet — Chain ID: 97

See also

Parameters

0x-prefixed 20-byte address

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

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

Ready to call this in production?

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