> ## Documentation Index
> Fetch the complete documentation index at: https://docs.peaq.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# Checking Balances

> Check a peaq wallet balance using ethers.js or Subscan. Fetch balances for EVM addresses and convert values from wei to PEAQ.

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:

```bash theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
npm install ethers
```

### 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:

```javascript theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
import { ethers } from "ethers";

// peaq mainnet. For agung, use https://peaq-agung.api.onfinality.io/public
const peaqProvider = new ethers.JsonRpcProvider("https://quicknode1.peaq.xyz");
```

### 3. Fetch the wallet balance

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

```javascript theme={"theme":{"light":"github-light-default","dark":"github-dark"}}
async function getPeaqBalance(address) {
    try {
        const balanceBigInt = await peaqProvider.getBalance(address);
        const balanceEth = ethers.formatEther(balanceBigInt);
        console.log(`Balance of ${address}: ${balanceEth}`);
    } catch (error) {
        console.error('Error fetching balance:', error);
    }
}

// Example usage:
const myAddress = "0xYourPeaqAddress";
getPeaqBalance(myAddress);
```

### 4. Check the same balance in Subscan

To check a balance by hand, use the block explorer:

* Open [peaq Subscan](https://peaq.subscan.io/) for mainnet or [agung Subscan](https://agung-testnet.subscan.io) 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.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.