eth_getBalance - Arbitrum
Example code for the eth_getBalance json-rpc method. Сomplete guide on how to use eth_getBalance json-rpc in GetBlock.io Web3 documentation.
This method retrieves the account balance of a given address. The balance is returned in wei, the smallest unit of Ether.
Parameters
address
string
yes
The account address to query (0x-prefixed).
block
string
yes
Block number or tag. Can be: "latest", "earliest", "pending" or a hex-encoded block number.
Request
curl --location 'https://go.getblock.us/<ACCESS_TOKEN>' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"id": "getblock.io",
"params": [
"0xb8b2522480f850eb198ada5c3f31ac528538d2f5",
"latest"
]
}'import axios from 'axios'
let data = JSON.stringify({
"jsonrpc": "2.0",
"method": "eth_getBalance",
"id": "getblock.io",
"params": [
"0xb8b2522480f850eb198ada5c3f31ac528538d2f5",
"latest"
],
};
let config = {
method: "post",
maxBodyLength: Infinity,
url: "https://go.getblock.us/<ACCESS_TOKEN>",
headers: {
"Content-Type": "application/json",
},
data: data,
};
axios
.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});
Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": "0x20a2c3a842980"
}Reponse Parameter Definition
result
string (hex)
Account balance in wei
Use case
eth_getBalance is used to:
Display a user's wallet balance in dApps and wallets
Check on-chain balances for dashboards or explorers
Validate whether an account can pay gas fees
Automated scripts can monitor whale wallets or treasury wallets
DeFi apps check collateral levels or borrowing capacity
Error handling
403
Forbidden
Missing or invalid ACCESS_TOKEN.
-32602
Invalid argument
Wallet address isn't accurate or incomplete
Integration with Web3
The eth_getBalance can help developers:
Fetch balances dynamically without requiring a transaction
Power trustless dashboards and explorers
Validate user accounts before executing transactions
Track portfolio values in real time
Access historical balances using specific block numbers
Last updated
Was this helpful?