Balances
Get balance
You can check your account's balance using SDK.
const balances = await unique.balance.get({
address: account.address
});
console.log(balances);
The output will resemble the following:
{
available: '270171775322286038926',
locked: '0',
free: '270171775322286038926',
total: '270171775322286038926',
reserved: '0',
staked: '0',
unstaked: '0',
canstake: '270171775322286038926',
vested: [],
decimals: 18,
tokenSymbol: 'UNQ'
}
Let's understand balance meaning:
available
: the balance user can transfer. Most application should operate with this balancelocked
: the balance locked by staking or vestingfree
: the sum ofavailable
andlocked
reserved
: the balance reserved by collator selection pallettotal
: the sum offree
andreserved
balancestaked
: the balance locked by stakingunstaked
: the balance that has been unstaked and awaiting unlocking period (~ 7 days)canstake
: the balance user can stakevested
: the balance locked by vesting palletdecimals
: all balances are in the wei. This field shows what is the decimals parttokenSymbol
: token symbol
Transfer
The account can transfer tokens in available
status.
await unique.balance.transfer({
amount: '100',
to: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY"
});
By default amount
is set in wei.
It is also possible to specify transfer in coins.
await unique.balance.transfer({
amount: '100.44',
to: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY",
isAmountInCoins: true // <--- in this case the transfer amount will be 100.44e18
});