eth_getBalance - Ethereum
Returns the balance of the account of a given address.

Parameters

  1. 1.
    DATA, 20 Bytes - address to check for balance.
  2. 2.
    QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter.
1
params: [
2
'0xc94770007dda54cF92009BFF0dE90c06F603a09f',
3
'latest'
4
]
Copied!

Returns

QUANTITY - hex value of the current ETH balance for the given address, measured in wei.

Example

Request
Curl
Postman
1
curl https://eth-mainnet.alchemyapi.io/v2/your-api-key \
2
-X POST \
3
-H "Content-Type: application/json" \
4
-d '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],"id":0}'
Copied!
1
URL: https://eth-mainnet.alchemyapi.io/v2/your-api-key
2
RequestType: POST
3
Body:
4
{
5
"jsonrpc":"2.0",
6
"method":"eth_getBalance",
7
"params":["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"],
8
"id":0
9
}
Copied!
Result
1
{
2
"jsonrpc": "2.0",
3
"id": 0,
4
"result": "0x7c2562030800"
5
}
Copied!

Converting eth_getBalance response into ETH

To convert the hex string response, measured in Wei to a decimal value measured in ETH we need to complete two steps:
  1. 1.
    Convert the hex response into decimal (Wei)
  2. 2.
    Convert the Wei decimal into ETH decimal (10^18 wei = 1 eth)
Depending on what library or language you are using, there are several options here.
Python
JavaScript
1
# conversion from hex string to decimal
2
wei_in_dec = int("hex strong response",16)
3
4
# conversion from Wei to ETH
5
ethBalance = wei_in_dec / (10**18)
Copied!
1
// conversion from hex string to decimal
2
dec = parseInt("hex strong response", 16)
3
4
// conversion from Wei to to ETH
5
ethBalance = dec*(10**18)
Copied!
Ethereum API
Alchemy Documentation