# near

## Description

The `transfer` function is an asynchronous function that facilitates the transfer of a specified amount of cryptocurrency from one account to another on the NEAR blockchain.

## Parameters

| Parameter    | Data Type | Description                                               |
| ------------ | --------- | --------------------------------------------------------- |
| `privateKey` | string    | The private key of the sender's NEAR account.             |
| `accountId`  | string    | The account ID of the sender's NEAR account.              |
| `receiver`   | string    | The account ID of the recipient's NEAR account.           |
| `value`      | string    | The amount of cryptocurrency to be transferred (in NEAR). |
| `env`        | string    | The environment in which the transaction is performed     |

## Response

| Field  | Data Type | Description                                                                     |
| ------ | --------- | ------------------------------------------------------------------------------- |
| code   | number    | Indicates the status of the transaction (1: success, 0: failure).               |
| result | string    | The hash of the transaction if successful, or an error message if unsuccessful. |

## 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/wallet-lib
OR
yarn add @nest25/wallet-lib
```

### Request

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

{% code overflow="wrap" %}

```javascript
// import Nest SDK
import { Wallet } from 'nest25/wallet-lib';

// Create a new instance of the Wallet class
const wallet = new Wallet();

const testMnemonic = 'divorce poverty spend fire symbol market good skull rebel surge giggle album';
// receiver address
const receiver = '0xd040591F093eacFAB8734350aac24703a0081f29';

const main = async () => {
  // transfer 10000 yactoNEAR from the test mnemonic to the receiver address
  const response = await wallet.transfer('btc',testMnemonic,receiver,'10000');
  // print the response
  console.log(response);
};

main();
```

{% endcode %}

### Response

{% code overflow="wrap" %}

```sh
 {
        code: 1,
        result: '5oWsXKXkTYxWUeBtyhaC6xxx7ZNRXW5qq1PJpbas1y4zQqgD9mxPGBF2zCeUkVHornFDo63hriUdVGuPp49u5Tvy'
      }
```

{% endcode %}

## Use Cases

* **Transfer Bitcoin:** The `transfer` function can be used to transfer a specific amount of Bitcoin from one address to another. It requires the private key of the sender's address, the amount to be transferred, the recipient's address, the desired environment (e.g., testnet or mainnet), the sender's address, and the ECC object for cryptographic operations.
* **Error Handling:** The function handles potential errors during the transfer process. If any step fails, an error object with a code and description is returned, indicating the cause of the failure.

###


---

# 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/wallet-sdk/transfer/near.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.
