eth_getTransactionByHash
https://api.triport.io/polygonReturns the transaction object for a given transaction hash on Polygon, or `null` if the transaction is unknown or still pending.
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.
txHashstringrequired0x-prefixed hex (66 characters total).Response
When the transaction is unknown or has not yet been seen:
{
"jsonrpc": "2.0",
"id": 1,
"result": null
}hashstringnoncestring0x-hex.blockHashstring | nullnull while pending.blockNumberstring | null0x-hex; null while pending.transactionIndexstring | null0x-hex; null while pending.fromstringtostring | nullnull for contract-creation transactions.valuestring0x-hex.gasstring0x-hex.gasPricestring0x-hex.inputstring0x-hex.chainIdstring0x89 (137) for Polygon mainnet.Errors
Polygon RPC calls return errors inside the standard JSON-RPC error object. The
codes most relevant to this method:
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The API key's free 7-day trial period has ended; upgrade to a paid tier to continue. |
-32002 | tier_insufficient | Your tier is below the minimum for the requested method. The data block carries current_tier, required_tier, and upgrade_url. |
-32003 | rate_limited | The per-tier RPS limit was exceeded. The data block carries limit_rps, retry_after_sec, and upgrade_url. |
-32601 | method_unknown | The 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/blockNumberofnullmeans 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 calleth_getTransactionReceiptfor the execution status, effective gas used, and emitted logs. - For low-latency pending detection, prefer a WebSocket
newPendingTransactionssubscription 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-encoded0x-hex strings, not JSON numbers. - To fetch a transaction by its position instead of its hash, use
eth_getTransactionByBlockHashAndIndexoreth_getTransactionByBlockNumberAndIndex. - This method belongs to the
polygon_read_rpccategory, so it draws from the same per-tier RPS budget as the other Polygon read methods.