eth_getBalance - Celo RPC Method
Query account balance on Celo. Essential for wallet applications and mobile stablecoin payments (MiniPay 10M+ wallets), remittances, humanitarian aid, and local currency stablecoins (cUSD, cNGN, cEUR) on the mobile-first L2 powering 500K+ daily active users and $2B+ monthly stablecoin volume.
Returns the balance of a given address on Celo.
Why Celo? Build on the mobile-first L2 powering 500K+ daily active users and $2B+ monthly stablecoin volume with phone number-based addressing, sub-cent fees, 150+ country adoption, Nightfall privacy layer, and Opera browser integration.
When to Use This Method
eth_getBalance is fundamental for mobile payment developers, fintech builders, and teams targeting emerging markets:
- Wallet applications: Display user balances and enable balance-dependent operations on Celo
- Transaction validation: Verify accounts have sufficient funds before submitting transactions to Celo
- DeFi monitoring: Track collateral positions, liquidity pools, and TVL across mobile stablecoin payments (MiniPay 10M+ wallets), remittances, humanitarian aid, and local currency stablecoins (cUSD, cNGN, cEUR)
- Accounting and reconciliation: Cross-reference on-chain balances against off-chain ledger entries for financial reporting
Common Use Cases
1. Display Formatted Wallet Balance with Ether Conversion
Retrieve and display a human-readable balance for any address on Celo. Convert the wei result to ether client-side using your web3 library.
import { JsonRpcProvider, formatEther } from 'ethers';
const provider = new JsonRpcProvider('https://api-celo-mainnet-archive.n.dwellir.com/YOUR_API_KEY');
async function displayBalance(address) {
const balanceWei = await provider.getBalance(address);
const balance = formatEther(balanceWei);
console.log(`Balance: ${balance} Celo`);
return balance;
}
displayBalance('0x471EcE3750Da237f93B8E339c536989b8978a438');2. Monitor Whale Wallet Activity with Polling and Threshold Alerts
Poll a high-value wallet on Celo at regular intervals. Trigger an alert when the balance crosses a defined threshold, useful for tracking DeFi movements or exchange hot wallet activity.
from web3 import Web3
import time
w3 = Web3(Web3.HTTPProvider('https://api-celo-mainnet-archive.n.dwellir.com/YOUR_API_KEY'))
address = '0x471EcE3750Da237f93B8E339c536989b8978a438'
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 Celo')
if current_balance > w3.to_wei(1000, 'ether'):
print(f'Whale alert: wallet exceeds 1000 Celo')
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 Celo.
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-celo-mainnet-archive.n.dwellir.com/YOUR_API_KEY")
address := common.HexToAddress("0x471EcE3750Da237f93B8E339c536989b8978a438")
// 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) orfromWei(web3.py) rather than relying on node-side conversion, which the JSON-RPC does not provide - Use
pendingtag cautiously: Balances returned with thependingblock tag may reflect unconfirmed state changes and differ from finalized on-chain values - For batch balance queries, use
eth_callwith multicall: When querying balances for many addresses, bundle them through a multicall contract to reduce individual RPC round-trips
Code Examples
Error Handling
| Error Code | Message | Description |
|---|---|---|
| -32602 | Invalid params | Invalid address format or block parameter |
| -32000 | Execution error | Node execution error |
Related Methods
eth_getCode- Get contract bytecodeeth_getTransactionCount- Get account nonce
eth_getBlockReceipts
Return every transaction receipt in a block on Celo. Useful for indexers, analytics pipelines, and event backfills across mobile stablecoin payments (MiniPay 10M+ wallets), remittances, humanitarian aid, and local currency stablecoins (cUSD, cNGN, cEUR).
eth_getCode
Get contract bytecode on Celo. Essential for verifying smart contracts for mobile stablecoin payments (MiniPay 10M+ wallets), remittances, humanitarian aid, and local currency stablecoins (cUSD, cNGN, cEUR).