Skip to main content

View Account Balances

The Accounts contract provides the following views:

balance

Get the account balance of a specific account.

Parameters

  • ParamAgentID: account's AgentID.

Returns

  • A map of [token_color] -> [amount].

Examples

balances := chain.GetAccountBalance(agentID)
// require.NoError(t, ctx.Err) // happens in GetAccountBalance() wrapper function

totalAssets

Get the total colored balances controlled by the chain.

Returns

  • A map of [token_color] -> [amount] .
balances:= chain.GetTotalAssets()

accounts

Get a list of all accounts existing on the chain.

Returns

  • A list of accounts (AgentIDs).
accounts := chain.GetAccounts()

getAccountNonce

Get the current nonce for a given account.

Parameters

  • ParamAgentID: Account's AgentID.

Returns

  • The current nonce.
ret, err := chain.CallView(accounts.Contract.Name, accounts.FuncGetAccountNonce.Name,
accounts.ParamAgentID, iscp.NewAgentID(address, 0),
)
require.NoError(t, err)
nonce, _, err := codec.DecodeUint64(ret.MustGet(accounts.ParamAccountNonce)