eth_getTransactionCount - Monad
Example code for the eth_getTransactionCount JSON-RPC method. Complete guide on how to use eth_getTransactionCount JSON-RPC in GetBlock Web3 documentation.
This method returns the number of transactions sent from an address (the nonce).
Parameters
address
string
Yes
The address to get the transaction count for.
blockNumber
string
No
Block number in hex, or "latest", "earliest", "pending", "safe", "finalized".
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x727752abbf7a9ef2f3c15e322dd43bf642d26eb7", "latest"],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0x727752abbf7a9ef2f3c15e322dd43bf642d26eb7", "latest"],
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x1a"
}Response Parameters
result
string
The number of transactions sent from the address in hexadecimal.
Use Case
The eth_getTransactionCount method is essential for:
Getting the correct nonce for new transactions
Transaction building and signing
Detecting pending transactions
Wallet transaction management
High-frequency trading nonce management
Account activity analysis
Error Handling
403
Forbidden
Missing or invalid ACCESS-TOKEN.
-32602
Invalid params
Invalid address format.
-32000
Resource not found
Block not found.
-32601
Failed to parse request
syntax error
Web3 Integration
Last updated
Was this helpful?