eth_getBalance - Base
Example code for the eth_getBalance JSON-RPC method. Complete guide on how to use eth_getBalance JSON-RPC in GetBlock Web3 documentation.
This method returns the ETH balance of a specified address on the Base network. Since Base uses ETH as its native gas token, this method returns the native token balance in wei.
Parameters
address
string
Yes
The 20-byte address to check the balance of
blockParameter
string
Yes
Block number in hex, or "latest", "earliest", "pending"
Request
curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x4200000000000000000000000000000000000006", "latest"],
"id": "getblock.io"
}'import axios from 'axios';
const data = JSON.stringify({{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x4200000000000000000000000000000000000006", "latest"],
"id": "getblock.io"
});
const config = {
method: 'post',
url: 'https://go.getblock.io/<ACCESS-TOKEN>/',
headers: {
'Content-Type': 'application/json'
},
data: data
};
axios(config)
.then(response => console.log(JSON.stringify(response.data)))
.catch(error => console.log(error));Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x56bc75e2d63100000"
}Response Parameters
jsonrpc
string
JSON-RPC protocol version ("2.0")
id
string
Request identifier matching the request
result
string
Hexadecimal balance in wei
Use Cases
Wallet Balance Display: Show user's ETH balance in wallet interfaces.
Transaction Validation: Verify sufficient balance before sending transactions.
Portfolio Tracking: Aggregate balances across multiple addresses.
Smart Contract Verification: Check contract balances for DeFi applications.
Historical Analysis: Query balances at specific block heights.
Error Handling
-32602
Invalid params
Invalid address format or block parameter
-32603
Internal error
Node internal failure
-32600
Invalid request
Malformed JSON-RPC request
Web3 Integration
Last updated
Was this helpful?