Ethereum

Ethereum

Basic Operations

These are the operations almost every Ethereum integration needs on day one: read an account's ETH balance, look up a transaction and its receipt, fetch a block, call a contract's view function, and pull the gas price and nonce you need before sending. Each one is a plain JSON-RPC POST to https://ethereum.therpc.io/YOUR_API_KEY. The examples below run unmodified against chain 1.

Retrieving Basic Information

Start with two reads that everything else builds on. eth_blockNumber returns the height of the current chain head as a hex string — handy for confirming your endpoint is live and tracking how far behind you are. eth_getBalance returns an account's balance, but mind the units: the value comes back in wei, the smallest denomination, so you divide by 10^18 (ETH has 18 decimals) to read it as ETH. A balance of 0xde0b6b3a7640000 is one whole ETH.

Get Latest Block Number

{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}

Check Account Balance

{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": [
"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"latest"
],
"id": 1
}

Transaction Operations

There are two ways to look at a transaction. eth_getTransactionByHash returns the transaction itself — sender, recipient, value, gas settings, and whether it is still pending or already mined. eth_getTransactionReceipt returns the outcome after it lands in a block: the status field (0x1 success, 0x0 revert), the block it was included in, gas actually used, and the full array of event logs the transaction emitted. A null receipt means the transaction has not been mined yet, so receipts are what you poll while waiting for confirmation.

Get Transaction Status

{
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": [
"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
],
"id": 1
}

Check Transaction Receipt

{
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": [
"0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"
],
"id": 1
}

Block Information

You can fetch a block either by its number with eth_getBlockByNumber or by its hash with eth_getBlockByHash. By-number also accepts the named tags — latest, safe, finalized, pending, earliest — which is how you read at proof-of-stake finality instead of at the head. Both take a boolean second parameter: pass false to get just the list of transaction hashes (smaller, faster), or true to get every transaction expanded into a full object inline.

Get Block by Number

{
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params": [
"0xE81224",
false
],
"id": 1
}

Get Block by Hash

{
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params": [
"0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae",
false
],
"id": 1
}

Smart Contract Interactions

Two methods cover reading from contracts. eth_call executes a function against the current state without sending a transaction or spending gas — this is how you read an ERC-20 balanceOf, a Uniswap pool's reserves, or any view function. The data field carries the ABI-encoded selector and arguments. eth_getCode returns the deployed bytecode at an address; a non-empty result confirms the address is a contract rather than an externally owned account, and 0x means there is no code there.

Call Contract Method

{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"data": "0x70a08231000000000000000000000000742d35Cc6634C0532925a3b844Bc454e4438f44e"
},
"latest"
],
"id": 1
}

Get Contract Code

{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"latest"
],
"id": 1
}

Network Status

Two checks tell you about the node and the network. net_version returns the network ID as a string — 1 for Ethereum mainnet — which is a quick way to confirm you have not accidentally pointed at Sepolia or Holesky. eth_syncing reports whether the node is still catching up: it returns false once fully synced, or an object with current and highest block numbers while it is still importing. Reads served while a node is mid-sync can be stale, so this is worth checking if results look behind.

Get Network Version

{
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
"id": 1
}

Check Node Sync Status

{
"jsonrpc": "2.0",
"method": "eth_syncing",
"params": [],
"id": 1
}

Gas and Nonce

Before you broadcast a transaction you need two values. eth_gasPrice returns a single suggested price in wei — the legacy path; for EIP-1559 type-2 transactions you would instead build maxFeePerGas and maxPriorityFeePerGas from eth_feeHistory and eth_maxPriorityFeePerGas. eth_getTransactionCount returns the account's nonce, the count of transactions it has already sent. The nonce sequences transactions from an address: each one must use the next integer in order, and a gap leaves later transactions stuck in the queued pool until the missing nonce arrives.

Get Gas Price

{
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": [],
"id": 1
}

Get Transaction Count (Nonce)

{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
"latest"
],
"id": 1
}

Implementation Examples

  • JavaScript / TypeScript — ethers.js and web3.js wrappers for these calls against chain 1
  • Python — web3.py equivalents for balances, receipts, and contract reads
  • Java / Kotlin — web3j bindings for the same operations
  • Tools & SDKs — the full set of language clients for the Ethereum endpoint

Ready to call this in production?

Free tier covers personal projects. Pay-as-you-go scales without a card.