Util

isTerraNativeAsset

Checks wether asset is a Terra Native asset

Parameters

  • asset

getTerraNativeAsset

Returns Terra Native asset from denom

Parameters

  • denom

getTerraNativeDenom

Returns Terra Native asset from denom

Parameters

  • asset

getTerraChains

Helper to get chain definitions (chainId + lcd)

Parameters

mergeChainIds

Helper to merge ChainIds into given ClientConfigs

Parameters

  • chains
  • config

getPrefix

Get address prefix

Returns string Prefix of an address

getGasPrices

Returns gas prices

Parameters

  • $0 Object
    • $0.url
    • $0.network
    • $0.cacheTime (optional, default 1000*60*60)
  • url string API enpdoint
  • cacheTime number (optional) Time in milliseconds to get gas prices from cache to avoid extra requests for same data. Use 0 to disable cache. Default value: One hour.

Returns GasPrices Gas prices of all Terra native assets

getGasPriceByAsset

Returns gas price for given asset

Parameters

  • $0 Object
    • $0.url
    • $0.asset
    • $0.network
    • $0.cacheTime (optional, default 1000*60*60)
  • url string API enpdoint
  • asset Asset Asset to get gas price for
  • network Network
  • cacheTime number (optional) Time in milliseconds to get gas prices from cache to avoid extra requests for same data. Use 0 to disable cache. Default value: One hour.

Returns GasPrices Gas prices of all Terra native assets

calcFee

Calculates fee by given estimated gas and gas price

Parameters

  • estimatedGas
  • gasPrice

getAccount

Returns account infos

Parameters

  • address
  • lcd

getEstimatedFee

Estimates fee paid by given Terra native (fee) asset

Note: LCDClient (via terra.js) supports already an estimateFee function, but it requires another request to get data of AccountInfo However, there is a more simple way (very similar to terra-station - check its src/txs/Tx.tsx + src/txs/send/SendForm.tsx)

Steps: 1. Get gas prices 2. Estimate gas 3. Estimate fee

Parameters

  • $0 Object
    • $0.chainId
    • $0.cosmosAPIURL
    • $0.sender
    • $0.recipient
    • $0.amount
    • $0.asset
    • $0.feeAsset
    • $0.memo
    • $0.network

Returns BaseAmount Fee amount