Skip to main content
This guide shows how to read a wallet balance on peaq with ethers.js, and how to look the same balance up in Subscan when you want to check it by hand.

Prerequisites

  • Basic understanding of JavaScript and Node.js.
  • ethers.js installed, and you know how to initialize a provider.
  • The wallet address you want to check.
  • An RPC endpoint for peaq or agung.

Instructions

1. Set up your environment

Ensure you have node and npm installed, then run:

2. Initialize the provider

In your JavaScript file, for example checkBalance.js, import ethers and create a provider pointed at the network you want, peaq mainnet or the agung testnet:

3. Fetch the wallet balance

Pass the address to the provider’s getBalance method. The address must be in EVM format, starting with 0x:

4. Check the same balance in Subscan

To check a balance by hand, use the block explorer:
  • Open peaq Subscan for mainnet or agung Subscan for testnet.
  • Enter the wallet address in the search bar and press Enter.
  • Read the balance from the account page.

5. Interpreting the results

getBalance returns the balance in wei, the smallest unit. ethers.formatEther converts it to PEAQ. Subscan already shows the converted amount.

Summary

peaq is EVM-compatible, so ethers.js reads balances the same way it does on any EVM chain. Subscan covers the case where you want to check an address without writing code.