Balances, Gas and Transaction Fee Utilities
This page details the utility functions for token balances, gas calculations, and transaction fees in Skip Go.
Getting token balances
To query token balances, you can use the balances
function or via the REST API. You have the option to specify a set of token denoms to query or leave the array empty to fetch balances for all denoms associated with an address.
- When no denoms are specified: The response will include only the denoms for which you have a balance.
- When denoms are specified: The response will include balances for all the specified denoms. If you have no balance for a given denom, it will be included with a balance of zero.
If there is an error fetching a given denom (e.g. the chain is down), the response will include an error message for that denom.
The balance query is currently compatible with all Skip Go-supported assets, excluding cw20 assets, across svm, evm, and Cosmos chains.
Getting info about gas and fees
Video Overview
Here’s a video overview of our gas and transaction fee tooling.
These functions are useful for getting information about our default gas and fee values or for estimating the fee for a particular transaction (e.g. so you can build a working MAX button).
getRecommendedGasPrice
This returns the gas price (i.e. the price of a single unit of gas) the API recommends you use for transactions on a particular chain.
GasPrice
is a cosmjs type giving the recommended fee denom and recommend price amount (fee/gas):
getFeeInfoForChain
This will return high, medium, and low gas prices for a particular chain, given by chainId
, along with the default fee denom as a FeeAsset
object:
An undefined response indicates that the API cannot find up-to-date gas price information for the chain.
Settings on ExecuteRouteOptions
for customizing how gas & fees are set on transactions
ExecuteRouteOptions.getGasPrice
This field in ExecuteRouteOptions
allows you to override our default gas price on a per chain basis for any transactions created in the router (e.g. in executeRoute
):
getGasPrice?: (chainId: string) => Promise<GasPrice | undefined>;
The argument is a function that takes in a chain ID and returns a gas price for that chain as a GasPrice
object from CosmJS
If you provide a function that only returns a price for a subset of chains, the router will use its default price in cases where yours is missing. If it can’t find a default price for a chain, it will error.
ExecuteRouteOptions.gasAmountMultiplier
This field in ExecuteRouteOptions
allows you to override the default gas multiplier used by default in the SDK. The default value is 1.5. Increasing this value provides higher confidence that transactions will not run out of gas while executing, but increases the fee for the end user.
The gas multiplier increases a transaction’s gasAmount
multiplicatively. To get a final gas amount, the router:
- Simulates a transaction to get an initial gasAmount
- Multiplies the gas consumed in the simulation by
gasAmountMultiplier