Base
eth_getTransactionCount
The eth_getTransactionCount method returns the number of transactions sent from a specified address, which is also known as the "nonce". This value is crucial for creating new transactions, as each transaction from an account must use a nonce value exactly one higher than the previous transaction.
Use Cases
- Transaction creation and signing
- Nonce management for transaction sequences
- Account activity analysis
- Identifying stuck transactions
- Address validation (EOA vs Contract)
- Wallet synchronization
- Transaction replay prevention
- Transaction queue management
Method Details
This method returns the current nonce value for an address, which represents the number of transactions sent from that address.
Response Example
Block Tag Meanings
The blockNumber parameter accepts several special values:
latest: Current state after all pending transactions are executedpending: Current state plus pending transactions in the mempoolearliest: Genesis block statesafe: Latest block considered safe by networkfinalized: Latest block that has achieved finality
Using pending is especially important for nonce management when sending multiple transactions in sequence.
Practical Example
Nonce Management Strategies
Advanced: Account Activity Analysis
Important Notes
- The first transaction from a new account must use nonce 0
- Each subsequent transaction must increment the nonce by exactly 1
- Transactions with a nonce higher than expected will remain pending until all lower nonces are processed
- If a transaction with a specific nonce is dropped, you can resubmit a new transaction with the same nonce
- Using the
pendingtag is crucial when creating multiple transactions in sequence
See also
- eth_sendRawTransaction - Submit raw signed transactions to the Ethereum network
- eth_getTransactionByHash - Retrieve detailed information about a transaction using its hash
Parameters
The address to check for transaction count
Block number in hex format or block tag