TriportRPC

eth_getTransactionCount

POSThttps://api.triport.io/v1/eth

Returns the number of transactions sent from an address — its nonce — at a given block.

Ethereumeth_read_rpcfree — 10 RPS (free) / 20 (basic) / 100 (pro) / 250 (business)

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

Parameters are positional (a JSON array of exactly two elements).

addressstring (20-byte hex, 0x-prefixed)required
The account address to query.
blockstring | objectrequired
Block tag — latest, pending, earliest, safe, finalized — or a hex block number (e.g. "0x10d4f"), or a block reference object such as { "blockHash": "0x..." }. Use pending to get the next nonce for signing.

Response

Response fields

FieldTypeDescription
resultstringThe transaction count (nonce) as a hex-encoded quantity. Decode to an integer to use as the next nonce. "0x1f" = 31.

Errors

Errors are returned in the standard JSON-RPC error envelope ({ "jsonrpc": "2.0", "id": …, "error": { "code", "message" } }).

CodeMeaningWhen it happens
-32001trial_expiredThe API key's trial period has ended; upgrade to a paid tier to continue.
-32003rate_limitedYou exceeded the requests-per-second limit for your tier (10 RPS on free). Back off and retry.

See Errors for the full error envelope and shared codes.

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/v1/eth", {
  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: ["0xb60e8dd61c5d32be8058bb8eb970870f07233155", "pending"],
  }),
});


const { result } = await res.json();
const nextNonce = parseInt(result, 16); // 31

TypeScript SDK (@triport/sdk)

import { Triport } from "@triport/sdk";


const triport = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });


const countHex = await triport.eth.getTransactionCount(
  "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  "pending",
);
const nextNonce = parseInt(countHex, 16);

Python (triport-sdk)

import os
from triport import Triport


triport = Triport(api_key=os.environ["TRIPORT_API_KEY"])


count_hex = triport.eth.get_transaction_count(
    "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
    "pending",
)
next_nonce = int(count_hex, 16)

Notes

  • Signing transactions: always use the pending tag when fetching a nonce to sign with. Using latest ignores transactions you have already broadcast but that are not yet mined, which can produce a nonce collision (nonce too low) on submission.
  • Hex decoding: the result is a hex quantity with no leading zeros ("0x0" for an account that has never sent a transaction). Decode with parseInt(result, 16) / int(result, 16).
  • Related methods: eth_getBalance for the account balance at a block, and eth_sendRawTransaction to broadcast the signed transaction you build with this nonce.