# getBalance

## Description

The `getBalance` function you provided is specific to the Solana blockchain. It retrieves the balance of a given address.

## Parameter

| Parameter | Data Type | Description                                                                                 |
| --------- | --------- | ------------------------------------------------------------------------------------------- |
| `env`     | string    | The environment or network (e.g., "mainnet", "testnet") in which the Solana address exists. |
| `address` | string    | The Solana address for which the balance needs to be retrieved.                             |

## 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.      |
| `balance` | number    | The balance of the specified Solana address in SOL (converted to a readable format). |

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

```sh
npm install @nest25/solana-lib
OR
yarn add @nest25/solana-lib
```

### Request

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

```javascript
const {Solana} = require("@nest25/solana-lib")

const Sol = new Solana();

async function main () {
    const balance = await Sol.getBalance("HyAEtjw6d4qEf7ew7LUN8UV7Hes3wXk9yBL6kG9yCpfP");
    console.log(balance);
}

main();
```

### Response

```sh
 { code: 1, balance: 18.692812614 }
```

## Use Cases

* This `getBalance function` can be used for various purposes such as displaying the account balance to the user, verifying account funds, or performing balance-related calculations.


---

# 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/solana-sdk/getbalance.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.
