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 ID -> amount
(the base token is identified by an empty token ID).
Examples
- Solo
- Solo (Schema)
- Rust (Schema)
- Go (Schema)
balances := chain.L2Assets(agentID)
b := coreaccounts.ScFuncs.Balance(ctx)
b.Params.AgentID().SetValue(agentID)
b.Func.Call()
require.NoError(t, ctx.Err)
balances := b.Results.Balances()
let b = coreaccounts::ScFuncs::balance(ctx);
b.params.agent_id().set_value(&agentID);
b.func.call();
let balances = b.results.balances();
b := coreaccounts.ScFuncs.Balance(ctx)
b.Params.AgentID().SetValue(agentID)
b.Func.Call()
balances := b.Results.Balances()
totalAssets
Get the total funds controlled by the chain.
Returns
- A map of [token_color] -> [amount] .
- Solo
- Solo (Schema)
- Rust (Schema)
- Go (Schema)
balances := chain.L2TotalAssets()
b := coreaccounts.ScFuncs.TotalAssets(ctx)
b.Func.Call()
require.NoError(t, ctx.Err)
balances := b.Results.Balances()
let b = coreaccounts::ScFuncs::total_assets(ctx);
b.func.call();
let balances = b.results.balances();
b := coreaccounts.ScFuncs.TotalAssets(ctx)
b.Func.Call()
balances := b.Results.Balances()
accounts
Get a list of all accounts that exist on the chain.
Returns
A list of accounts (Agent IDs).
- Solo
- Solo (Schema)
- Rust (Schema)
- Go (Schema)
accounts := chain.L2Accounts()
a := coreaccounts.ScFuncs.Accounts(ctx)
a.Func.Call()
require.NoError(t, ctx.Err)
accounts := a.Results.AllAccounts()
let a = coreaccounts::ScFuncs::accounts(ctx);
a.func.call();
let accounts = a.results.all_accounts();
a := coreaccounts.ScFuncs.Accounts(ctx)
a.Func.Call()
accounts := a.Results.AllAccounts()