# Query Balance

## **Prerequisites**

Install @polkadot/api, the suggested version is ^4.15.1 (equal or above 4.15.1)

## Sample code

```javascript
const API = require("@polkadot/api")
const cloverTypes = require('@clover-network/node-types');

async function getBalance(address) {
    const wsProvider = new API.WsProvider('wss://api-ivy.clover.finance');
    const api = await API.ApiPromise.create({
        provider: wsProvider,
        types: cloverTypes
    });
    const { parentHash } = await api.rpc.chain.getHeader();
    const {
        data: { free: balance },
    } = await api.query.system.account.at(parentHash, address);
    return balance.toString();
}

getBalance('5DZabq7G2m12g1GUuqs66CCAVcmzdWRkXsGxpi4dgXFEcLEb').then(console.log)
```

Furthermore you may use **formatBalance** from **@polkadot/util** to format the display

�


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.clv.org/portal/technical-documentation/query-banalnce.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
