eth_getBalance | Aurora

Aurora API method that returns the balance of a specific account in Wei, the smallest unit of ether. This method allows developers to retrieve the current balance of a Fantom account for various purposes, such as checking available funds or displaying balance information.

πŸ‘

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Parameters

  • address β€” the address to check the balance of.

  • quantity or tag β€” the integer of a block encoded as hexadecimal or the string with:

    • latest β€” the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.

    • safeβ€”the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or severe propagation latency.

    • finalized β€” the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, and it would require at least 1/3 of the staked amount to be burned.

    • earliest β€” the earliest available or genesis block

    • pendingβ€” the pending state and transactions block. This is the current state of transactions that have been broadcast to the network but have not yet been included in a block.

      πŸ“˜

      See the default block parameter and How The Merge Impacts Ethereum’s Application Layer.

Response

  • quantity β€” the integer value of the current balance in Wei

eth_getBalance code examples

const { Web3 } = require("web3");
const NODE_URL = "CHAINSTACK_NODE_URL";
const web3 = new Web3(NODE_URL);

async function getBalance(address, block) {
  const balance = await web3.eth.getBalance(address, block)
  console.log(balance)
 }
 
 getBalance("0x3E3CB6D0cA24E7491580A7757b9bB70e16Bfb552", "latest" )
const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.providers.JsonRpcProvider(NODE_URL);

const getBalance = async (address, block) => {
    const balance = await provider.send("eth_getBalance", [address, block]);
    console.log(balance);
  };

getBalance("0x3E3CB6D0cA24E7491580A7757b9bB70e16Bfb552", "latest")
from web3 import Web3  
node_url = "CHAINSTACK_NODE_URL" 

address = web3.to_checksum_address("0x3E3CB6D0cA24E7491580A7757b9bB70e16Bfb552")
balance = web3.eth.get_balance(address, "latest") 
print(balance) 

Use case

One practical use case for eth_getBalance is to check the balance of an account for a program that scans the balance periodically and fills up the account when the balance drops below a certain value.

Try the eth_getBalance RPC method yourself

Language
Click Try It! to start a request and see the response here!