eth_call
https://api.triport.io/v1/ethereumExecutes a read-only message call against the EVM at a chosen block, without creating, signing, or broadcasting a transaction.
eth_call runs a contract message call in the context of the current EVM state
(or a historical block) and returns whatever the call would have returned, as
hex-encoded data. Nothing is mined: there is no transaction, no signature, no
gas is spent, and no state change is persisted. It is the workhorse for reading
on-chain data — token balances, allowances, pool reserves, the output of any
view/pure function, or a dry-run of a state-changing function to preview its
return value or revert reason.
Because the call is simulated, from is optional and may be any address; supply
it only when the target contract's logic depends on msg.sender. The second
parameter selects the block at which state is read — pass "latest" for current
state, a hex block number for a historical read, or a tag like "pending",
"safe", or "finalized".
If the underlying call reverts, the request returns a JSON-RPC error (code 3,
"execution reverted") rather than a result; decode the data field to recover
the revert reason. For gas estimation use eth_estimateGas instead.
Parameters
Positional params array: [transaction, blockParameter].
1. transaction (, required)objecttostring (20-byte hex address)requireddatastring (hex)optionalfromstring (20-byte hex address)optionalmsg.sender). Defaults to the zero address.gasstring (hex)optionalgasPricestring (hex)optionalvaluestring (hex)optionalmsg.value).2. blockParameter (string, required)objectResponse
Response fields
| Field | Type | Description |
|---|---|---|
jsonrpc | string | Always "2.0". |
id | number | string | Echoes the request id. |
result | string (hex) | ABI-encoded return data of the call. "0x" if the function returns nothing. Decode against the function's return ABI (here, 0x…2540be400 = 10000000000 = 10,000 USDT at 6 decimals). |
Errors
| Code | Meaning | When it happens |
|---|---|---|
-32001 | trial_expired | The API key's trial period has ended; upgrade to a paid tier to continue. |
-32003 | rate_limited | Per-tier RPS limit exceeded (10 / 20 / 100 / 250 RPS for free / basic / pro / business). Retry after backing off. |
-32602 | Invalid params | Malformed transaction object, bad address, or missing block parameter. |
3 | Execution reverted | The simulated call reverted; the error.data field holds the ABI-encoded revert reason. |
Every error follows the shared JSON-RPC error envelope — see Errors for the full structure and handling guidance.
Examples
JavaScript (fetch)
const res = await fetch("https://api.triport.io/v1/ethereum", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.TRIPORT_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
id: 1,
method: "eth_call",
params: [
{
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
data: "0x70a08231000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b",
},
"latest",
],
}),
});
const { result } = await res.json();
console.log(BigInt(result).toString()); // raw balanceTypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const triport = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const result = await triport.ethereum.call(
{
to: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
data: "0x70a08231000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b",
},
"latest",
);
console.log(BigInt(result).toString());Python (triport-sdk)
import os
from triport import Triport
triport = Triport(api_key=os.environ["TRIPORT_API_KEY"])
result = triport.ethereum.call(
{
"to": "0xdAC17F958D2ee523a2206206994597C13D831ec7",
"data": "0x70a08231000000000000000000000000ab5801a7d398351b8be11c439e05c5b3259aec9b",
},
"latest",
)
print(int(result, 16))Notes
- No gas is spent.
eth_callnever costs ETH and never alters state; it only reads. To get the gas a real transaction would use, calleth_estimateGas. - Reverts vs. results. A reverting call returns a JSON-RPC error (code
3), not an empty result. Always check forerrorbefore decodingresult. - Historical reads. Passing a hex block number reads state as of that block, subject to the node's archive depth.
frommatters only for permissioned logic. Set it when the contract gates behavior onmsg.sender; otherwise it can be omitted.- Related methods:
eth_estimateGas,eth_getBalance,eth_getCode.