Get gas fee for specific tx's

This guide describes how to retreive the gas fee for specific transactions including transferring native token, ERC20 token, and NFT.

Request Endpoint:

POST /api/transactions/build

1. Get gas fee for a native token transfer

The following endpoint retrieves the gas fee for a native token transfer.

POST /api/transactions/build

Request Body

Body ParamTypeDescription
typeStringThe type of tx. For a native transfer, this will be TRANSFER
walletIdStringThe id of the wallet that will execute the tx
toStringThe destination wallet address
secretTypeStringThe blockchain of the tx
valueIntegerThe amount to transfer in decimal value
{
    "type": "TRANSFER",
    "walletId": "46f3c87b-cbf8-4a41-99f3-e943a6e34087",
    "to": "0xCd14E16BeA4709F5A9Cba9080889e24748B24809",
    "secretType": "MATIC",
    "value": 0.49
}

Response Body

{
    "success": true,
    "result": {
        "walletId": "46f3c87b-cbf8-4a41-99f3-e943a6e34087",
        "type": "MATIC_TRANSACTION",
        "gas": 21000,
        "maxFeePerGas": 85513648045,
        "maxPriorityFeePerGas": 85513648031,
        "value": 490000000000000000,
        "to": "0xCd14E16BeA4709F5A9Cba9080889e24748B24809"
    }
}

2. Get gas fee for an ERC20 token transfer

The following endpoint retrieves the gas fee for an ERC20 token transfer.

POST /api/transactions/build

Request Body

Body ParamTypeDescription
typeStringThe type of tx. For an ERC20 transfer, this will be TOKEN_TRANSFER
walletIdStringThe id of the wallet that will execute the tx
toStringThe destination wallet address
tokenAddressStringThe token's contract address
secretTypeStringThe blockchain of the tx
valueIntegerThe amount to transfer in decimal value
{
    "type": "TOKEN_TRANSFER",
    "walletId": "46f3c87b-cbf8-4a41-99f3-e943a6e34087",
    "to": "0xCd14E16BeA4709F5A9Cba9080889e24748B24809",
    "tokenAddress": "0x53286df83a02e7398963ff4bbda4688115b3ab41",
    "secretType": "MATIC",
    "value": 3
}

Response Body

{
    "success": true,
    "result": {
        "walletId": "46f3c87b-cbf8-4a41-99f3-e943a6e34087",
        "type": "MATIC_ERC20_TRANSACTION",
        "gas": 62508,
        "maxFeePerGas": 85513648045,
        "maxPriorityFeePerGas": 85513648031,
        "value": 3000000000000000000,
        "to": "0xCd14E16BeA4709F5A9Cba9080889e24748B24809",
        "tokenAddress": "0x53286df83a02e7398963ff4bbda4688115b3ab41"
    }
}

3. Get gas fee for an NFT transfer

The following endpoint retrieves the gas fee for an NFT transfer.

POST /api/transactions/build

Request Body

Body ParamTypeDescription
typeStringThe type of tx. For an ERC20 transfer, this will be NFT_TRANSFER
walletIdStringThe id of the wallet that will execute the tx
toStringThe destination wallet address
tokenAddressStringThe NFT's contract address
secretTypeStringThe blockchain of the tx
tokenIdIntegerThe id of the NFT token you want to transfer
{
    "type": "NFT_TRANSFER",
    "walletId": "46f3c87b-cbf8-4a41-99f3-e943a6e34087",
    "to": "0xCd14E16BeA4709F5A9Cba9080889e24748B24809",
    "tokenAddress": "0xfe70a8d4c3c1c53aea3753d38eec27d7f5137b3a",
    "secretType": "MATIC",
    "tokenId": "100"
}

Response Body

{
    "success": true,
    "result": {
        "walletId": "46f3c87b-cbf8-4a41-99f3-e943a6e34087",
        "type": "MATIC_ERC721_TRANSACTION",
        "gas": 68557,
        "maxFeePerGas": 82948238604,
        "maxPriorityFeePerGas": 82948238590,
        "value": 0,
        "to": "0xCd14E16BeA4709F5A9Cba9080889e24748B24809",
        "tokenAddress": "0xfe70a8d4c3c1c53aea3753d38eec27d7f5137b3a",
        "from": "0xd633e3765364F4a6Cce2dAE0af8e0CB0554e120E",
        "tokenId": "100"
    }
}