Get Approx Fees

Get Approx fees

The API is used to get approx fee rates. use the following code.

// Get Wallet Instance
let walletInstance=await liminalJs
                                .Coin(CoinsEnum.eth)
                                .Wallets()
                                .Get({walletId:310});
//Get Approx Fees
let response= await walletInstance.GetApproxFees();

// Response
if(response?.success===true){
  console.log(`Success => ${JSON.stringify(response?.data)}`);
}
else
{
  console.log(`fail => ${response?.message}`);
}
// Get Wallet Instance
let walletInstance:Wallet=await liminalJs
                                .Coin(CoinsEnum.eth)
                                .Wallets()
                                .Get({walletId:310});
//Get Approx Fees
let response:ApproxFeesResultDataWrapper= await walletInstance.GetApproxFees();

// Response
if(response?.success===true){
  console.log(`Success => ${JSON.stringify(response?.data)}`);
}
else
{
  console.log(`fail => ${response?.message}`);
}

Note:

This API is working on UTXO and EVM base chains only.

You will get the following response from the GetApproxFees method. It is JSON representation Only.

{
   "fees":"0.00036000000168",
   "feesRate":"1.1",
   "ERC20TokenFees":"0.00054000000252"
}

Full Example

import { CoinsEnum,LiminalEnvironment, LiminalJs } from "@lmnl/liminaljs";

const main = async () => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
                clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance=await liminalJs
                                        .Coin(CoinsEnum.eth)
                                        .Wallets()
                                        .Get({walletId:310});
        //Get Approx Fees
        let response= await walletInstance.GetApproxFees();

        // Response
        if(response?.success===true){
          console.log(`Success => ${JSON.stringify(response?.data)}`);
        }
        else
        {
          console.log(`fail => ${response?.message}`);
        }
    }
    catch (ex) {
        throw ex;
    }
};
main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));
import {
    CoinsEnum,
    LiminalEnvironment,
    LiminalJs,
    ApproxFeesResultDataWrapper,
    Wallet
} from "@lmnl/liminaljs"

const main = async (): Promise<void> => {
    try {
        // Instance of Liminal Js
        let liminalJs = new LiminalJs(LiminalEnvironment.test);
        await liminalJs
            .Authenticate({
                clientId: "YOUR_CLIENT_ID",
                clientSecret: "YOUR_CLIENT_SECRET"
            })
            .AuthenticateWithAccessToken();

        // Get Wallet Instance
        let walletInstance:Wallet=await liminalJs
                                        .Coin(CoinsEnum.eth)
                                        .Wallets()
                                        .Get({walletId:310});
        //Get Approx Fees
        let response:ApproxFeesResultDataWrapper= await walletInstance.GetApproxFees();

        // Response
        if(response?.success===true){
          console.log(`Success => ${JSON.stringify(response?.data)}`);
        }
        else
        {
          console.log(`fail => ${response?.message}`);
        }
    }
    catch (ex) {
        throw ex;
    }
}

main().then((resolve) => console.log("Complete")).catch((error) => console.log(error));

Did this page help you?