Avalanche
Ready to call this in production?
Free tier covers personal projects. Pay-as-you-go scales without a card.
Avalanche
Free tier covers personal projects. Pay-as-you-go scales without a card.
This page collects the operations developers reach for first when building on the Avalanche C-Chain: reading the latest block, checking an AVAX balance, looking up transactions and their receipts, fetching blocks by number or hash, calling smart contracts such as Trader Joe or Aave, checking network status, and pulling the gas price and nonce you need before sending a transaction. Each example is a ready JSON-RPC payload you can POST to https://avalanche.therpc.io/YOUR_API_KEY.
Two reads form the foundation of almost every Avalanche C-Chain integration. eth_blockNumber returns the height of the latest block, confirming your connection is live and current. eth_getBalance returns an account's balance, but note the value comes back in wei as a hexadecimal string — divide it by 10^18 to convert it into a human-readable AVAX amount.
Once a transaction is on the Avalanche C-Chain, two calls tell you everything you need. eth_getTransactionByHash returns the transaction itself — sender, recipient, value, gas, and whether it has been included in a block yet. eth_getTransactionReceipt returns the receipt after the transaction is mined, including its success or failure status, the block it landed in, the gas actually used, and all emitted event logs. Given the C-Chain's roughly one-to-two-second finality, the receipt usually appears within seconds of broadcasting.
You can fetch any block on the Avalanche C-Chain two ways: eth_getBlockByNumber takes a block height (or a tag like latest), while eth_getBlockByHash takes the block's hash. Both accept a boolean second parameter that controls detail level — pass true to receive full transaction objects embedded in the block, or false to receive only the transaction hashes, which is lighter and faster when you just need the list.
Reading from smart contracts on the Avalanche C-Chain uses two calls. eth_call executes a contract's view or pure function without sending a transaction or spending gas — this is how you read an ERC-20 balance on Trader Joe, query a lending position on Aave, or fetch a price feed. eth_getCode returns the deployed bytecode at an address, which lets you confirm a contract exists and is deployed before interacting with it.
Two quick checks confirm you are talking to the right Avalanche network and that the node is healthy. net_version returns the network's chain ID as a string — 43114 for the C-Chain mainnet — so you can assert your client is not accidentally pointed at a testnet. eth_syncing reports the node's sync state: false when the node is fully caught up, or an object describing sync progress otherwise.
Before you sign and broadcast a transaction on the Avalanche C-Chain, two reads set it up correctly. eth_gasPrice returns the current gas price in wei, which you use to price your transaction in AVAX so it confirms promptly. eth_getTransactionCount returns an account's nonce — the number of transactions it has already sent. The nonce sequences transactions from an address: each new transaction must use the next nonce in order, or it will be rejected or stuck, so always fetch the latest count before sending.