githubEdit

eth_getTransactionCount - Arbitrum

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. This value is also known as the nonce. It is required when creating new transactions because each transaction from the same sender must have a unique nonce.

Parameters

Parameter
Type
Required
Description

address

string

yes

The address for which to retrieve the transaction count. Must be a hex string with 0x prefix.

block

string

yes

Block context for the query. Accepted values include latest, earliest, pending, or a block number in hex.

Request

curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
   "jsonrpc": "2.0",
   "method": "eth_getTransactionCount",
    "params": [
        "0xb8b2522480f850eb198ada5c3f31ac528538d2f5",
        "latest"
    ],
    "id": "getblock.io"
}'

Response

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

Reponse Parameter Definition

Field
Type
Description

result

string (hex)

Number of transactions sent from this address. Equivalent to the account nonce.

Use case

The eth_getTransactionCount :

  • Determining the correct nonce before sending a new transaction

  • Replaying transaction history for analytics or dashboards

  • Monitoring the activity of accounts in explorers

  • Validating whether a wallet has pending transactions

  • Preventing double-spending by ensuring nonces are sequential

Error handling

Status Code
Error Message
Cause

403

Forbidden

Missing or invalid ACCESS_TOKEN.

-32602

Invalid argument

  • Invalid address

  • Block parameter not recognized

Integration with Web3

The eth_getTransactionCount method helps developers to:

  • Manage nonces automatically when sending transactions

  • Prevent duplicate transactions by checking the latest nonce

  • Build reliable wallet transaction pipelines

  • Track account activity in explorers and dashboards

  • Detect pending transactions by comparing pending vs latest values

  • Support batch transaction systems that depend on precise nonce control

Last updated

Was this helpful?