# transfer

## Description

The `transfer` function is an asynchronous function that transfers a specified amount of ERC20 tokens from the caller's wallet to the specified receiver address and returns the transaction receipt.

## Parameters

| Parameter         | Type   | Description                                                                                                               |
| ----------------- | ------ | ------------------------------------------------------------------------------------------------------------------------- |
| `blockchain`      | string | Takes a string parameter specifying the name of the blockchain network (For eg. bsc, polygon, eth, ava, gnosis, moonbeam) |
| `contractAddress` | string | Requires the contract address of the token (ERC20) that is already deployed                                               |
| `receiver`        | string | Expects the receiving account address for the transfer of the token (ERC20)                                               |
| `amount`          | string | Requires an amount of tokens to be transferred                                                                            |
| `privateKey`      | string | The private key of the account to sign the transaction                                                                    |

## Response

| Property          | Type   | Description                            |
| ----------------- | ------ | -------------------------------------- |
| `Promise<Object>` | object | Returns the transaction receipt object |

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

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

### Request

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

```
// import the Nest SDK
const { ERC20 } = require('@nest25/evm-chains-lib');

// create a new instance of the ERC20 class
const erc20 = new ERC20();

// define the main function
const main = async () => {
    // call the transfer method
    const receipt = await erc20.transfer('ava','0x3c40d011838f0ecd5b601104eeb5e27172c92231','0x13CC66D6611bb754647Bf2977881eA0e35A48FB4',"1","your-private-key");

    // print the receipt
    console.log({ receipt });
};
// call the main function
main();
```

### Response

```
 {
  receipt: {
    type: 2,
    chainId: 43113,
    nonce: 1,
    maxPriorityFeePerGas: BigNumber { _hex: '0x3b9aca00', _isBigNumber: true },
    maxFeePerGas: BigNumber { _hex: '0x0bdfd63e00', _isBigNumber: true },
    gasPrice: null,
    gasLimit: BigNumber { _hex: '0x5444', _isBigNumber: true },
    to: '0x3c40d011838F0EcD5B601104EEb5E27172C92231',
    value: BigNumber { _hex: '0x00', _isBigNumber: true },
    data: '0xa9059cbb00000000000000000000000013cc66d6611bb754647bf2977881ea0e35a48fb40000000000000000000000000000000000000000000000000000000000000001',
    accessList: [],
    hash: '0x7c898df5d92011d5ad1e5abc5cf6d45fe9e82e236d7a58bcc79de67bc6faf3bb',
    v: 1,
    r: '0xb488a4d4208aaab0a36674c47afda8c4dd8dbc3d9f09d256478d4836d37a09c8',
    s: '0x7a441f0b8a5617a93af70124a48e1b998e4b5e311d56d88d5d74f0ffd06a6bbb',
    from: '0xE668C72D4C67236A712Ce69A91C74358586f31ed',
    wait: [Function (anonymous)]
  }
}
```

## Use Cases

* **Token transfer:** The primary use case for the transfer function is to transfer a specified amount of ERC20 tokens from one address to another on a given blockchain network.
* **Payment processing:** The transfer function can also be used to process payments in a decentralized way by allowing users to send ERC20 tokens as payment for goods or services.
* **Exchange trading:** The transfer function can be used in decentralized exchanges to facilitate the trading of ERC20 tokens between different parties.
