TriportRPC

eth_getTransactionByHash

POSThttps://api.triport.io/polygon

Returns the transaction object for a given transaction hash on Polygon, or `null` if the transaction is unknown or still pending.

Polygonfree — 15 RPS (free) / 20 RPS (basic) / 100 RPS (pro) / 250 RPS (business)

eth_getTransactionByHash looks up a single Polygon transaction by its 32-byte hash and returns the full transaction object. Use it to confirm that a transaction you broadcast was accepted, to read back its calldata and value, or to find which block it landed in.

The method resolves both mined and pending transactions. If the hash has been seen in the mempool but not yet included in a block, blockHash, blockNumber, and transactionIndex are returned as null while the rest of the object is populated. If the hash is completely unknown to the node — never broadcast, dropped, or replaced — the result is null. A null result is not an error: the JSON-RPC envelope still returns HTTP 200 with "result": null.

Polygon's block time is roughly 2.1 seconds (vs ~12s on Ethereum), so a freshly submitted transaction is usually mined within a couple of blocks. When you poll for inclusion, poll at about the block interval — every ~2 seconds — rather than tighter, to avoid burning your RPS budget on a transaction that is not yet mined. For latency-sensitive pending detection, prefer a WebSocket newPendingTransactions subscription over polling this method. To read the execution outcome (status, gas used, logs) once mined, use eth_getTransactionReceipt.

Parameters

The params array takes a single positional element.

txHashstringrequired
32-byte transaction hash, 0x-prefixed hex (66 characters total).

Response

When the transaction is unknown or has not yet been seen:

{
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}
hashstring
32-byte hash of the transaction.
noncestring
Number of transactions made by the sender prior to this one, as 0x-hex.
blockHashstring | null
Hash of the block this transaction was included in; null while pending.
blockNumberstring | null
Block number this transaction was included in, as 0x-hex; null while pending.
transactionIndexstring | null
Index of the transaction within its block, as 0x-hex; null while pending.
fromstring
20-byte address of the sender.
tostring | null
20-byte address of the receiver; null for contract-creation transactions.
valuestring
Value transferred in wei (MATIC has 18 decimals), as 0x-hex.
gasstring
Gas supplied by the sender, as 0x-hex.
gasPricestring
Gas price provided by the sender in wei, as 0x-hex.
inputstring
The calldata sent with the transaction, as 0x-hex.
chainIdstring
Chain id of the transaction; 0x89 (137) for Polygon mainnet.

Errors

Polygon RPC calls return errors inside the standard JSON-RPC error object. The codes most relevant to this method:

CodeMeaningWhen it happens
-32001trial_expiredThe API key's free 7-day trial period has ended; upgrade to a paid tier to continue.
-32002tier_insufficientYour tier is below the minimum for the requested method. The data block carries current_tier, required_tier, and upgrade_url.
-32003rate_limitedThe per-tier RPS limit was exceeded. The data block carries limit_rps, retry_after_sec, and upgrade_url.
-32601method_unknownThe method is not part of the Polygon product, or the name is misspelled.

A malformed or wrong-length txHash is rejected as an invalid-params error before the lookup runs. See the shared errors reference for the full envelope, the data payload, and the complete code list.

Examples

JavaScript (fetch)

const res = await fetch("https://api.triport.io/polygon", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.TRIPORT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    jsonrpc: "2.0",
    id: 1,
    method: "eth_getTransactionByHash",
    params: [
      "0x6f3a1c8e5b9d2a47f0c1e8b6d4a2f9c3e7b1d0a5c8e2f4b6a9d1c3e5f7a0b2c4d",
    ],
  }),
});


const { result } = await res.json();
if (result === null) {
  console.log("transaction unknown or pending");
} else if (result.blockNumber === null) {
  console.log("seen in mempool, not yet mined");
} else {
  console.log(`included in block ${result.blockNumber}`);
}

TypeScript SDK (@triport/sdk)

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


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


const tx = await client.polygon.getTransactionByHash(
  "0x6f3a1c8e5b9d2a47f0c1e8b6d4a2f9c3e7b1d0a5c8e2f4b6a9d1c3e5f7a0b2c4d",
);


if (tx === null) {
  console.log("transaction unknown or pending");
} else if (tx.blockNumber === null) {
  console.log("seen in mempool, not yet mined");
} else {
  console.log(tx.from, "→", tx.to, tx.value);
}

Python (triport-sdk)

import os
from triport import Triport


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


tx = client.polygon.get_transaction_by_hash(
    "0x6f3a1c8e5b9d2a47f0c1e8b6d4a2f9c3e7b1d0a5c8e2f4b6a9d1c3e5f7a0b2c4d"
)


if tx is None:
    print("transaction unknown or pending")
elif tx["blockNumber"] is None:
    print("seen in mempool, not yet mined")
else:
    print(tx["from"], "->", tx["to"], tx["value"])

Notes

  • A blockHash / blockNumber of null means the transaction is still in the mempool. Poll at roughly the Polygon block interval (~2.1 s) until those fields populate to detect inclusion, then call eth_getTransactionReceipt for the execution status, effective gas used, and emitted logs.
  • For low-latency pending detection, prefer a WebSocket newPendingTransactions subscription instead of polling this method — polling a not-yet-mined hash wastes requests against your per-second budget.
  • All numeric fields (nonce, value, gas, gasPrice, blockNumber, transactionIndex, chainId) are quantity-encoded 0x-hex strings, not JSON numbers.
  • To fetch a transaction by its position instead of its hash, use eth_getTransactionByBlockHashAndIndex or eth_getTransactionByBlockNumberAndIndex.
  • This method belongs to the polygon_read_rpc category, so it draws from the same per-tier RPS budget as the other Polygon read methods.