# balanceOf

## Description

The `balanceOf` function is an asynchronous function that retrieves the balance of a specific token for a given address in a specified contract on a particular blockchain.

## Parameters

| Parameter         | Data Type | Description                                                                        |
| ----------------- | --------- | ---------------------------------------------------------------------------------- |
| `blockchain`      | string    | The name or symbol of the blockchain.                                              |
| `contractAddress` | string    | The address of the contract on the blockchain.                                     |
| `address`         | string    | The address for which the token balance is to be retrieved.                        |
| `tokenId`         | string    | The ID of the token for which the balance is to be retrieved.                      |
| `env`             | string    | The environment or network where the contract exists (e.g., 'mainnet', 'testnet'). |

## Response

| Field    | Data Type | Description                                                                     |
| -------- | --------- | ------------------------------------------------------------------------------- |
| `code`   | number    | A numeric value indicating the execution status (1 for success, 0 for error).   |
| `error`  | any       | The error object containing details about the encountered error, if applicable. |
| `result` | string    | The balance of the specified token for the given address.                       |

## Example Request and Response

### Prerequisites

Before making requests with Volary SDK, you must have it installed.

You can install Volary SDK using either **`npm`** or **`yarn`**. Use the following commands to install Volary SDK:

```jsx
npm install @nest25/evm-chains-lib
OR
yarn add @nest25/evm-chains-lib
```

### Request

Here is an example of how to make a `balanceOf` request using the Volary SDK:

```jsx
const { ERC1155 } = require('@nest25/evm-chains-lib');

const erc1155 = new ERC1155();
const privateKey = "your private key"

async function main() {
    const response = await erc1155.balanceOf('ava','0x1d224f9ba0c15058601e18b171e87cdadfc8de45',"0x1148d4a18e53f8072734325ed5e72dbb7aeb6fa6",'354856');
    console.log(response)
}

main();


```

### Response

```jsx
{ code: 1, result: '85' }
```

## Use Cases

* The `balanceOf` function can be used to retrieve the balance of a specific token for a given address in a contract.


---

# 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.volary.io/sdks-guide/blockchain-sdks/evm-chains-sdk/contracts/erc1155/balanceof.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.
