eth_getTransactionCount - BSC

Example code for the eth_getTransactionCount JSON RPC method. Сomplete guide on how to use eth_getTransactionCount JSON RPC in GetBlock Web3 documentation.

This method returns the number of transactions sent from an address (nonce) on the BNB Smart Chain. This is essential for creating new transactions, as each transaction requires the correct nonce.

Parameters

Parameter
Type
Required
Description

address

string

Yes

Address to get nonce for

blockNumber

string

Yes

Block number or "latest", "pending"

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_getTransactionCount",
    "params": ["0x8D97689C9818892B700e27F316cc3E41e17fBeb9", "latest"],
    "id": "getblock.io"
}'

Response Example

{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": "0x15"
}

Response Parameters

Parameter
Type
Description

result

string

Nonce in hex (0x15 = 21)

Use Cases

  • Get nonce for transaction signing

  • Track account activity

  • Detect pending transactions

  • Prevent nonce conflicts

Error Handling

Error Code
Description

-32602

Invalid params

-32603

Internal error

SDK Integration

Last updated

Was this helpful?