Docs
Docs
Home
Getting Started
Agent Tooling
CLI
Supported Chains
Acala
Aptos
Arbitrum
Arc
Asset Hub
Astar
Avalanche
Base
Berachain
Bifrost
Binance Smart Chain
Bittensor
Blast
Boba Network
Bridge Hub
Celo
Centrifuge
Chiliz
Cronos
Enjin
Ethereum
Etherlink
Flow EVM Gateway
Gnosis
Hydration
Hyperliquid
Immutable
Ink
IoTeX
Kusama
Linea
LISK
Manta Atlantic
Manta Pacific
Mantle
MegaETH
Monad
Movement
Neuroweb
opBNB
Optimism
Plasma
Polkadot
Polygon
Pulsechain
Robinhood
Ronin
Scroll
Sonic
Starknet
Taiko
Tempo
Sui
TRON
Unichain
Viction
World Chain
XDC Network
XX Network
Zetachain
zkSync Era
Zora
Supported ChainsZetachainJSON-RPC APIAccount Methods

eth_getBalance - Zetachain RPC Method

Query account balance on Zetachain. Essential for wallet applications and omnichain DeFi, native Bitcoin smart contracts, cross-chain asset management, and unified liquidity aggregation on the universal omnichain blockchain enabling cross-chain smart contracts across 50+ chains including Bitcoin.

Zetachain RPC endpoint: endpoint URLs, plans and pricing.

Returns the balance of a given address on Zetachain.

Why Zetachain? Build on the universal omnichain blockchain enabling cross-chain smart contracts across 50+ chains including Bitcoin with native Bitcoin support, 50+ chain interoperability via UNISON, no bridging required, and partnerships with Curve and SushiSwap.

When to Use This Method

eth_getBalance is fundamental for cross-chain dApp developers, Bitcoin DeFi builders, and teams requiring native multi-chain interoperability:

  • Wallet applications: Display user balances and enable balance-dependent operations on Zetachain
  • Transaction validation: Verify accounts have sufficient funds before submitting transactions to Zetachain
  • DeFi monitoring: Track collateral positions, liquidity pools, and TVL across omnichain DeFi, native Bitcoin smart contracts, cross-chain asset management, and unified liquidity aggregation
  • Accounting and reconciliation: Cross-reference on-chain balances against off-chain ledger entries for financial reporting
JSON-RPC request
{
  "jsonrpc": "2.0",
  "method": "eth_getBalance",
  "params": [
    "0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf",
    "latest"
  ],
  "id": 1
}

Common Use Cases

1. Display Formatted Wallet Balance with Ether Conversion

Retrieve and display a human-readable balance for any address on Zetachain. Convert the wei result to ether client-side using your web3 library.

JavaScript
import { JsonRpcProvider, formatEther } from 'ethers';

const provider = new JsonRpcProvider('https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY');

async function displayBalance(address) {
  const balanceWei = await provider.getBalance(address);
  const balance = formatEther(balanceWei);
  console.log(`Balance: ${balance} Zetachain`);
  return balance;
}

displayBalance('0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf');

2. Monitor Whale Wallet Activity with Polling and Threshold Alerts

Poll a high-value wallet on Zetachain at regular intervals. Trigger an alert when the balance crosses a defined threshold, useful for tracking DeFi movements or exchange hot wallet activity.

Python
from web3 import Web3
import time

w3 = Web3(Web3.HTTPProvider('https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY'))
address = '0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf'
threshold_wei = w3.to_wei(100, 'ether')

def monitor_balance():
    previous_balance = w3.eth.get_balance(address)
    while True:
        time.sleep(15)
        current_balance = w3.eth.get_balance(address)
        if abs(current_balance - previous_balance) > threshold_wei:
            print(f'Balance changed by more than 100 Zetachain')
        if current_balance > w3.to_wei(1000, 'ether'):
            print(f'Whale alert: wallet exceeds 1000 Zetachain')
        previous_balance = current_balance

monitor_balance()

3. Historical Balance Tracking Using Block Tags

Query an account's balance at a specific block height to build a historical balance timeline. This is essential for audit trails, tax reporting, and analyzing wallet behavior over time on Zetachain.

Go
package main

import (
    "context"
    "fmt"
    "log"
    "math/big"

    "github.com/ethereum/go-ethereum/common"
    "github.com/ethereum/go-ethereum/ethclient"
)

func main() {
    client, _ := ethclient.Dial("https://api-zetachain-mainnet.n.dwellir.com/YOUR_API_KEY")

    address := common.HexToAddress("0x5F0b1a82749cb4E2278EC87F8BF6B618dC71a8bf")

    // Query balance at a specific block number
    blockNumber := big.NewInt(1000000)
    historicalBalance, _ := client.BalanceAt(context.Background(), address, blockNumber)
    fmt.Printf("Historical balance at block 1,000,000: %s wei\n", historicalBalance.String())

    // Query latest balance for comparison
    currentBalance, _ := client.BalanceAt(context.Background(), address, nil)
    change := new(big.Int).Sub(currentBalance, historicalBalance)
    fmt.Printf("Balance change: %s wei\n", change.String())
}

Best Practices

  • Cache balances with short TTL: Set a 2-5 second cache duration for balance queries to reduce RPC calls while keeping data fresh enough for most UI use cases
  • Convert wei to ether client-side: Use formatEther (ethers.js) or fromWei (web3.py) rather than relying on node-side conversion, which the JSON-RPC does not provide
  • Use pending tag cautiously: Balances returned with the pending block tag may reflect unconfirmed state changes and differ from finalized on-chain values
  • For batch balance queries, use eth_call with multicall: When querying balances for many addresses, bundle them through a multicall contract to reduce individual RPC round-trips

Code Examples

Error Handling

Error CodeMessageDescription
-32602Invalid paramsInvalid address format or block parameter
-32000Execution errorNode execution error

Related Methods

  • eth_getCode - Get contract bytecode
  • eth_getTransactionCount - Get account nonce

eth_getBlockByHash

Retrieve complete block data by block hash on Zetachain. Essential for cross-chain dApp developers, Bitcoin DeFi builders, and teams requiring native multi-chain interoperability building on the universal omnichain blockchain enabling cross-chain smart contracts across 50+ chains including Bitcoin.

eth_getCode

Get contract bytecode on Zetachain. Essential for verifying smart contracts for omnichain DeFi, native Bitcoin smart contracts, cross-chain asset management, and unified liquidity aggregation.

On this page

When to Use This MethodCommon Use Cases1. Display Formatted Wallet Balance with Ether Conversion2. Monitor Whale Wallet Activity with Polling and Threshold Alerts3. Historical Balance Tracking Using Block TagsBest PracticesCode ExamplesError HandlingRelated Methods