⛏️transfer

Description

The estimateFee function is used to estimate the transaction fee for different types of ERC-20 token transfers.

Parameters

Parameter
Data Type
Description

blockchain

string

The blockchain on which the ERC20 token exists.

contract

string

The contract type, in this case, 'erc20'.

functionType

string

The type of function for which to estimate the fee, in this case, 'transfer'.

env

string

The environment or network of the blockchain.

amount (optional)

number

The amount of ERC20 tokens to be transferred.

Response

Field
Data Type
Description

code

number

The response code indicating the success or failure of the operation.

result

number

The estimated gas fee in the blockchain's native currency.

VLRYEstimate

number

The estimated gas fee in VLRY (a virtual currency).

USDEstimate

number

The estimated gas fee in USD.

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/evm-chains-lib
OR
yarn add @nest25/evm-chains-lib

Request

Here is an example of how to make a transfer request using the NEST® SDK:

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

const nft = new Nft('testnet');

async function main() {
    const result = await nft.estimateFee('eth', 'erc20', 'transfer', 1);
    console.log("result", result);
}

main();

Response

result {
        code: 1,
        result: 0.008017217841645946,
        VLRYEstimate: 100.9930000544191,
        USDEstimate: 15.148950008162863
      }

Use Cases

  1. User Wallet Integration: The estimateFee function can be used to provide users with an estimated transaction fee before they initiate a token transfer. This gives users the ability to make an informed decision about their transaction.

  2. DApp Transaction Confirmation: In a decentralized application (DApp), when a user initiates a token transfer, the DApp can call this function to display the estimated fee to the user before proceeding with the transaction. This enhances user experience and ensures transparency.

  3. Transaction Cost Comparison: For platforms or services that support multiple blockchain networks, this function can be used to compare transaction costs across different blockchains. This helps users choose the most cost-effective blockchain for their token transfers.

Last updated