eth_getBalance | zkEVM

Polygon zkEVM 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 zkEVM 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 ETH 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("0x038D8981cC8fB8421CB96e8EEe8093Fc1F2E63dC", "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("0x038D8981cC8fB8421CB96e8EEe8093Fc1F2E63dC", "latest")
from web3 import Web3  
node_url = "CHAINSTACK_NODE_URL" 

address = web3.to_checksum_address("0x038D8981cC8fB8421CB96e8EEe8093Fc1F2E63dC")
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!