eth_getTransactionCount
https://api.triport.ioReturns the number of transactions sent from a Polygon address — i.e. its nonce — at a given block.
eth_getTransactionCount returns the nonce of an account: the total number
of transactions that address has sent, counted up to and including the block you
specify. The value comes back as a hex-encoded quantity (e.g. "0x2a" = 42).
The nonce is the primary input for transaction signing. Every transaction an
account sends must carry a strictly increasing nonce; using the count returned
for the "pending" block tag gives you the next nonce to assign to a new
transaction.
High-throughput callers: if you are sending many transactions in quick succession (e.g. a bot), do not fetch the nonce per transaction. The RPC view lags behind transactions you have already broadcast but that are not yet mined, so you will reuse a nonce and get rejected — and you will burn your RPS budget. Fetch the
"pending"count once at startup, then track and increment the nonce locally, reconciling against the RPC only on error.
Parameters
Positional params array, two entries:
addressstring (20-byte hex, 0x-prefixed)requiredblockTagstringrequired"latest", "earliest", "pending", "safe", "finalized". Use "pending" to get the next nonce for signing.Response
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | Always "2.0". |
id | number | Echoes the request id. |
result | string | The transaction count (nonce) as a hex-encoded quantity. Decode to an integer before use (0x2a → 42). A never-used address returns "0x0". |
Errors
Errors are returned in the standard JSON-RPC envelope with a numeric code. See
errors.md for the full envelope and the data fields
(current_tier, required_tier, limit_rps, retry_after_sec, …).
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | Trial period for the key has ended. |
-32002 | tier_insufficient | Key's tier is below what the method requires. |
-32003 | rate_limited | Per-second rate limit for your tier exceeded; back off and retry after retry_after_sec. |
-32004 | subscription_expired | Paid subscription lapsed. |
-32005 | unauthorized | Missing or invalid API key. |
-32601 | method_unknown | Method not available on this key/chain. |
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_getTransactionCount",
params: ["0x0000000000000000000000000000000000001010", "pending"],
}),
});
const { result } = await res.json();
const nonce = parseInt(result, 16); // next nonce to sign withTypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const hexCount = await client.polygon.rpc<string>("eth_getTransactionCount", [
"0x0000000000000000000000000000000000001010",
"pending",
]);
const nonce = parseInt(hexCount, 16);Python (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
hex_count = client.polygon.rpc(
"eth_getTransactionCount",
["0x0000000000000000000000000000000000001010", "pending"],
)
nonce = int(hex_count, 16) # next nonce to sign withNotes
"latest"vs"pending":"latest"counts only mined transactions;"pending"also includes transactions queued in the mempool. For signing the next transaction, use"pending". For reporting how many transactions an account has confirmed, use"latest".- Local nonce management: see the high-throughput note above — track the nonce in your application and reconcile with the RPC only on conflict, rather than calling this method before every send.
- Historical reads: passing a hex block number returns the nonce as of that block, useful for backfills and audits. Deep historical lookups depend on the archive depth available on your tier.
- Related methods:
eth_sendRawTransaction(broadcast the signed transaction),eth_estimateGas, andeth_getBalance.