Get Balance
Once you have your L1 assets on L2, you might want to check their balance. This guide explains how to do so by calling the three functions getL2BalanceBaseTokens
, getL2BalanceNativeTokens
and getL2NFTAmount
for the corresponding token types.
Example Code
- Get the AgentID from the sender by calling
ISC.sandbox.getSenderAccount()
.
ISCAgentID memory agentID = ISC.sandbox.getSenderAccount();
- To get the base token balance, you can call
getL2BalanceBaseTokens
using theagentID
.
uint64 baseBalance = ISC.accounts.getL2BalanceBaseTokens(agentID);
- To get the native token balance of a specific
NativeTokenID
, useISC.accounts.getL2BalanceNativeTokens
with theid
andagentID
.
NativeTokenID memory id = NativeTokenID({ data: nativeTokenID});
uint256 nativeTokens = ISC.accounts.getL2BalanceNativeTokens(id, agentID);
- To get the number of NFTs, use
ISC.accounts.getL2NFTAmount
with theagentID
.
uint256 nfts = ISC.accounts.getL2NFTAmount(agentID);
Full Example Code
packages/evm/evmtest/wiki_how_tos/GetBalance.sol
loading...