🔗evm

Description

The transfer function is used to transfer cryptocurrency from one account to another on a specified blockchain network. This function requires the sender's private key, the value to be transferred, the receiver's address, the blockchain network, and the environment (testnet or mainnet).

Parameters

ParameterTypeDescription

privateKey

string

The private key of the account sending the cryptocurrency.

value

string

The value of cryptocurrency to be transferred, specified in the smallest unit of the cryptocurrency.

receiver

string

The address of the account that will receive the cryptocurrency.

blockchain

string

The blockchain network on which the transfer will occur.

env

string

The environment on which the transfer will occur (testnet or mainnet).

Response

FieldTypeDescription

code

number

The status code of the operation (0 for failure, 1 for success).

result

object

The receipt of the transaction if the operation was successful.

error

string

The error message if the operation failed.

Example Request and Response

Prerequisites

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

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

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 Nest SDK:

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

// Create a new instance of the Wallet class
const wallet = new Wallet();
// test mnemonic for BTC mainnet (use the createWallet function to get one)
const testMnemonic = 'divorce poverty spend fire symbol market good skull rebel surge giggle album';
// receiver address
const receiver = '0xd040591F093eacFAB8734350aac24703a0081f29';

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

main();

Response

{
        code: 1,
        result: {
          type: 2,
          chainId: 43113,
          nonce: 3,
          maxPriorityFeePerGas: BigNumber { _hex: '0x59682f00', _isBigNumber: true },
          maxFeePerGas: BigNumber { _hex: '0x0bfda3a300', _isBigNumber: true },
          gasPrice: null,
          gasLimit: BigNumber { _hex: '0x5208', _isBigNumber: true },
          to: '0xd040591F093eacFAB8734350aac24703a0081f29',
          value: BigNumber { _hex: '0x016345785d8a0000', _isBigNumber: true },
          data: '0x',
          accessList: [],
          hash: '0x1decc8409d5f3c089df6e7de9b078fe7b4eda4e5b3d6779d7a7c239b77a52bb4',
          v: 0,
          r: '0xe0f10ac39c7eeba7f0b02af956d81a94ad85148aede38e9b4dd3318174d969ef',
          s: '0x7a81b46b0173be9b84f11a2e16fccea7e34f067d1eae8173683e7a9870302af6',
          from: '0xfDffeBC5938f6Ad00eA67F815a47a83922D227B0',
          confirmations: 0,
          wait: [Function (anonymous)]
        }
      }

Use Cases

  • Crypto Wallets: The transfer function can be used by crypto wallets to transfer cryptocurrency from one account to another.

  • Decentralized Exchanges: The transfer function can be used by decentralized exchanges to transfer cryptocurrency from one account to another when users are exchanging one cryptocurrency for another.

  • Crypto Payment Gateways: The transfer function can be used by crypto payment gateways to facilitate cryptocurrency transactions between buyers and sellers.

Last updated