eth_getTransactionCount
Last updated:
eth_getTransactionCount returns the total number of transactions that have
been sent from the given account, counted up to the specified block. Because
Ethereum assigns each transaction a sequential nonce starting at 0, this count
is the account's current nonce.
The single most common use is to obtain the next nonce when building and signing
a transaction. Query the address against the pending block tag — the result is
exactly the nonce you should assign to your next outgoing transaction, accounting
for any transactions you have already broadcast but that are not yet mined.
The result is returned as a hex-encoded quantity (e.g. "0x1f" for 31). Querying
against latest counts only mined transactions, while pending also includes
transactions sitting in the mempool — the two can differ if you have in-flight
transactions.
Parameters
This method takes no parameters.
Returns
| Field | Type |
|---|---|
| result | object |
Examples
curl https://triport.io/eth \
-X POST -H 'Content-Type: application/json' \
-H 'Authorization: Bearer <api-key>' \
-d '{"id":1,"method":"eth_getTransactionCount","params":[],"jsonrpc":"2.0"}'const res = await fetch("https://triport.io/eth", {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: "Bearer <api-key>" },
body: JSON.stringify({
"id": 1,
"method": "eth_getTransactionCount",
"params": [],
"jsonrpc": "2.0"
}),
});
const data = await res.json();import requests
resp = requests.post(
"https://triport.io/eth",
headers={"Authorization": "Bearer <api-key>"},
json={"id":1,"method":"eth_getTransactionCount","params":[],"jsonrpc":"2.0"},
)
print(resp.json())Usage
- Transport: HTTP (JSON-RPC).
- Networks: mainnet.
- Credit cost: 1 per call.
FAQ
- What does eth_getTransactionCount do?
- Returns the number of transactions sent from an address — its nonce — at a given block.
- How many credits does eth_getTransactionCount cost?
- eth_getTransactionCount costs 1 credit(s) per call on Triport by default.
- Is eth_getTransactionCount available over WebSocket?
- eth_getTransactionCount is an HTTP JSON-RPC method.