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
method on your SkipClient
instance 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.
Learn how to setup your SkipClient
instance in the Getting Started guide.
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).
SkipClient.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):
SkipClient.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.
SkipClient.getFeeForMessage
This will give you the estimated fee and gas for a particular multichainMsg returned by the API.
If you provide no additional arguments other than your signer and message, it will use the default gas price and gas amount multipliers in the skip-router, but you can override anything to customize your estimation for your use case:
- You can override the gas price in the
gasPrice
argument (By default, we’re pulling this data from various chain registries and serving it through the API) - You can override the gas amount multiplier, which provides a multiplicative buffer for the amount of gas the chain estimates a transaction will consume, in the
gasAmountMultiplier
argument. (By default, this is1.5
)
The return type of the function is a cosmjs.StdFee
, which includes the following fields:
amount
: The estimated fee amount and denom for the feegas
: The gas amount for the transaction
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