When transferring a non-native asset, the fees are paid using the native asset on that blockchain.
The example uses USDC and ETH and assumes you have already configured the Wallaby client. You can find more information on how to setup the client .
Once the SDK is initialized, you can retrieve all assets associated with the wallet using wallet.getWalletAssets(). Then filter down to find the asset details you need, as well as to find the network native token.
The network token will always have a type COIN and for the most part, contract address, and token standard will be null
const assetSymbol = 'USDC'
const chainName = 'ETHEREUM'
// TO-DO: Replace with your config.
const wallaby = new Wallaby(config)
// TO-DO: Replace with your walletId.
const allAssets = wallaby.wallet.getWalletAssets(walletId);
// TO-DO:
// 1. Replace chainName with the blockchain name for your token.
// 2. replace symbol with your token symbol.
const nativeToken = allAssets.find((asset) => asset.chainName === chainName && asset.config.type === AssetType.Coin)
const usdcToken = allAssets.find((asset) => asset.chainName === chainName && asset.assetSymbol === assetSymbol)
// didn't include `tokenStandard` because for native network tokens it is always `null`
const ethBalance = wallaby.wallet.getTokenBalance({
address: nativeToken.defaultAddress,
assetSymbol: nativeToken.assetSymbol,
chainName: nativeToken.chainName
})
const usdcBalance = wallaby.wallet.getTokenBalance({
address: usdcToken.defaultAddress,
assetSymbol: usdcToken.assetSymbol,
chainName: usdcToken.chainName,
tokenStandard: usdcToken.tokenStandard,
})
// OR you can do this using 1 API call:
const balances = wallaby.utils.fetchFromEndpoint({
endpoint: '/query/assets/bulk-balance',
method: RequestMethod.Post,
payload: {
assets: [ethToken, usdcToken].map((asset) => ({
address: asset.defaultAddress,
tokenStandard: asset.config.tokenStandard,
assetSymbol: asset.assetSymbol,
})),
},
});