Accounts
Get Hedera acount information using Arkhia's Json-RPC Relay.
info
To configure your web3Provider, please refer to the Getting Started Docs:
eth_getBalance
Get HBAR balance of an Hedera account.
Parameters
- Address: address to check for balance
Required
- Block: integer block number, or the string "latest", "earliest" or "pending", see the default block parameter
Returns
Hex string or Integer: Hedera balance of the given account
- Web3.js
- Node.js (Axios)
- Curl
/*Remove the preceding 0's from the account number. For example, if your HEDERA_ACCOUNT_NUMBER is 0.0.442577, you should use 442577*/const address = web3Provider.utils.toHex(`<HEDERA_ACCOUNT_NUMBER>`);const paddedAddress = web3Provider.utils.padLeft(address, 40);web3Provider.eth.getBalance(paddedAddress) .then((res)=> console.log(`-> Get Balance ${_addr} : ${res*Math.pow(10, -18)}`)) .catch(e => console.log(`-> Get Balance Error: ${e}`));
/*<ACCOUNT_ETHEREUM_ADDRESS> can be found on hashscan https://hashscan.io/#/mainnet/dashboardfor example: 0x0000000000000000000000000000000000067237*/import axios from 'axios';const data = JSON.stringify({ "jsonrpc": "2.0", "method": "eth_getBalance", "params": [ "<ACCOUNT_ETHEREUM_ADDRESS>" ], "id": 0});const config = { method: 'post', url: '<JSON_RPC_URL>/<YOUR_API_KEY>', headers: { 'Content-Type': 'application/json'}, data : data};async function main() { await axios(config) .then(function (response) { console.log(response.data)); }); .catch(function (error) { console.log(error); });}
# <ACCOUNT_ETHEREUM_ADDRESS> can be found on hashscan https://hashscan.io/#/mainnet/dashboard# for example: 0x0000000000000000000000000000000000067237curl --location --request POST '<JSON_RPC_URL>/<YOUR_API_KEY>' \--header 'Content-Type: application/json' \--data-raw '{ "jsonrpc": "2.0", "method": "eth_getBalance", "params": [ "<ACCOUNT_ETHEREUM_ADDRESS>" ], "id": 0}'