eth_getBalance
https://api.triport.io/Returns the native ETH balance of an account, in wei, at a given block.
eth_getBalance returns the amount of wei held by an Ethereum address at a
specific point in the chain's history. The balance is the native ETH balance
only — it does not include ERC-20 token balances, which live in their
respective token contracts.
Use this method to display an account's spendable ETH, to check a contract's treasury, or to confirm a deposit has landed. By varying the second parameter (the block tag) you can read the balance as of the latest block, a pending block, the genesis block, or any historical block height.
The result is a hex-encoded u256 string measured in wei (1 ETH = 10¹⁸ wei).
For example, 0x1bc16d674ec80000 is 2000000000000000000 wei = 2 ETH.
You are responsible for converting the hex value to a decimal and dividing by
10¹⁸ when presenting it to users.
Parameters
Positional params array: [address, block].
addressstring (0x-prefixed, 20 bytes / 40 hex chars)requiredblockstringoptionallatest, earliest, pending, or a 0x-prefixed hex block number. Defaults to latest if omitted.Response
Response fields
| Field | Type | Description |
|---|---|---|
result | string | Account balance in wei as a 0x-prefixed hex u256. Divide by 10¹⁸ for ETH. 0x1bc16d674ec80000 = 2 ETH. |
Errors
Errors are returned in the standard JSON-RPC envelope (error.code +
error.message). See errors.md for the full envelope and
shared codes.
| 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 | You exceeded the requests-per-second limit for your tier. Back off and retry. |
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_getBalance",
params: ["0x742d35Cc6634C0532925a3b844Bc9e7595f06b8b", "latest"],
}),
});
const { result } = await res.json();
const wei = BigInt(result);
console.log(`${Number(wei) / 1e18} ETH`); // 2 ETHTypeScript SDK (@triport/sdk)
import { Triport } from "@triport/sdk";
const client = new Triport({ apiKey: process.env.TRIPORT_API_KEY! });
const balanceWei = await client.eth.getBalance(
"0x742d35Cc6634C0532925a3b844Bc9e7595f06b8b",
"latest",
);
console.log(BigInt(balanceWei)); // 2000000000000000000nPython (triport-sdk)
import os
from triport import Triport
client = Triport(api_key=os.environ["TRIPORT_API_KEY"])
balance_wei = client.eth.get_balance(
"0x742d35Cc6634C0532925a3b844Bc9e7595f06b8b",
"latest",
)
print(int(balance_wei, 16) / 1e18) # 2.0Notes
- Wei, not ETH. The result is always in wei. Use a big-integer type
(
BigInt, Pythonint) — a 2 ETH balance overflows the JavaScript safe integer range when expressed in wei. - Block tags.
pendingreflects transactions not yet mined and may change;latestis the safest default for confirmed balances. Historical hex block numbers let you reconstruct a balance at any past height (archive lookups). - Native balance only. For ERC-20 token balances, call the token
contract's
balanceOfvia eth_call. - Rate limits are enforced per second per tier (no daily cap). On
-32003, honor exponential backoff rather than retrying immediately.