Token Balance

Examples from our RPC are used. If you want to look at information about archival nodes (more than 2 days ago), please use archival prefix in your URL (e.g. https://archival-rpc.mainnet.near.org) In this article, we always use POST methods to the same URL https://archival-rpc.mainnet.near.org. Body:

{
  "jsonrpc": "2.0",
  "id": "dontcare",
  "method": "EXPERIMENTAL_tx_status",
  "params": ["8uxq5BAC4zZL4Set7gtraqZSWduYXRUiNggpKhWmBnzK", "nf-finance.near"]
}

Every account has liquid balance (called amount) and stake (called locked). All calculation in tables are in yoctonear.

Total supply is the amount of tokens in the whole system. Each example is selected at the moment when no other changes is performed in the blockchain, so the only example could affect total supply.

Why does my balance change?

There are different scenarios why the amount of tokens could change on the account. Let's look at it on real examples.

Each example (except rewarding) contains fees user pays for the operation. You could read about fees calculation here.

Transfer of tokens

https://explorer.mainnet.near.org/transactions/6gUVYsdAsStzU5H2AyW7bxAdEL4RvJv5PL3b8DRnPVED

pine.near sent 1.64234 tokens to taka.near

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt.

We also have receipt for returning a change: it is made without fee.

For this example, final cost of transferring tokens was 22318256250000000000 * 2 / 10^24 = 0.0000446365125 Near Tokens.

Creating the account

https://explorer.mainnet.near.org/transactions/Hant2anxPJHm3sh8ncc5AWn5VpXTmwq6iyEumVoQcUJP

nearcrowd.near created account app.nearcrowd.near, gave the access key, transfer some tokens for that account. These 3 actions are usually go together.

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt.

We also have receipt for returning a change: it is made without fee. For this example, final cost of creating account and transferring tokens were 42455506250000000000 * 2 / 10^24 = 0.0000849110125 Near Tokens.

Deleting the account

https://explorer.mainnet.near.org/transactions/8nZeedU6RUnj65zxQYHrGx2Urx5sLe6J2T123xSNL2RK

It's not possible to delete not your account: user is always deleting their own account. User should provide beneficiary account that receive all tokens. User could provide the account that does not exist, in such case the tokens will burn.

wxx.near deleted their account with beneficiary vng.near

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt.

Note: we do not have the change. For this example, final cost of deleting account was 25554850000000000000 * 2 / 10^24 = 0.0000511097 Near Tokens.

Calling a function

https://explorer.mainnet.near.org/transactions/8oBZrKk8jkAzrsYasoL2DW9Yg6K2GznLhvoiXmSm7kHe

relayer.bridge.near invoked a function in the contract of client.bridge.near

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt. Receiver gets part of the fee as a reward for a possibility to invoke their function.

For this example, final cost of invoking the function was (250815301972200000000 + 3551880449426700000000) / 10^24 = 0.0038026957513989 Near Tokens. Reward was 0.0009903195442363 Near Tokens.

TODO: add Nomicon link about royalties when this issue will be resolved.

The example of calling a function could be more complex.

https://explorer.mainnet.near.org/transactions/DuGWWTK2sAxjffifJiJBv6hs3Hc8MdhpHnzgRJryV4Be

lulukuang.near invokes a function in a protocol of berryclub.ek.near. It triggers berryclub.ek.near to send the money to third account, farm.berryclub.ek.near. So we need to analyze 3 accounts in this scenario.

Adding the key

https://explorer.mainnet.near.org/transactions/A9767GbmRCLdeCpZYfKTQUqe17KyAu5JrZHanoRChMSV

slavon.near added the key to their own account.

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt.

Note: we do not have the change. For this example, final cost of adding the key was 21039071952900000000 * 2 / 10^24 = 0.0000420781439058 Near Tokens.

Deleting the key

https://explorer.mainnet.near.org/transactions/CfuXcVPy7vZNVabYKzemSwDdNF9fnhbMLaaDKjAMyw8j

77yen.near deleted the key from their own account.

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt.

Note: we do not have the change. For this example, final cost of adding the key was 20300612500000000000 * 2 / 10^24 = 0.000040601225 Near Tokens.

Deploying the contract

https://explorer.mainnet.near.org/transactions/3DN4XiQCX2EeSN5sjiaB4WBjJizthbhUfqQhCBcZK57A

ref-finance.near deployed the contract.

For such kind of transactions, sender pays 2 fees: for making receipt from transaction; for executing receipt.

Note: we do not have the change. For this example, final cost of deploying the contract was 256803307904900000000 * 2 / 10^24 = 0.0005136066158098 Near Tokens.

Receiving the reward for being validator

NB: No transaction/receipt is associated with such type of balance changing.

On the boundary of the epochs, validators receive reward. The platform gives 10% of minted tokens to special account treasury.near. You could think about treasury.near as about reward to the whole system to keep it in working order. Total sum of the rewards (including treasury.near) is the increase of total supply in the system.

If the validator does not change the stake during the epoch, all the reward will go to their stake. Liquid balance will remain the same.

baziliknear.poolv1.near had 4M tokens on their locked balance. Their reward for the epoch was 633186852212418719477211708 / 10^24 = 633.1868522124187 tokens.

If the validator decrease the stake during the epoch, it will be actually decreased at the boundary between the epochs. The reward will also go to the liquid balance in such case.

astro-stakers.poolv1.near decided to put the reward to liquid balance, so they invoked a command (e.g. ping). We can see that the stake does not change between the epochs.

d1.poolv1.near decided to slightly decrease the stake size, so the reward and the part of the stake are on the liquid balance.

artemis.poolv1.near received the reward and stopped being validator at that epoch, so all the stake are on the liquid balance, stake becomes zero.

The reword value is calculated based on stake size and number of calculated blocks per epoch. Read more about it here

If the validator increase the stake during the epoch, stake will be increased in next few blocks, we do not need to wait for the moment of the epoch boundary. For current epoch, blockchain will take into account stake value fixed at the start of the epoch.

https://explorer.mainnet.near.org/transactions/HajXjY1gSf47jakXP44ERecjFE2hFvF4FgRyQzNdZzDZ

elecnodo.near put 245.7788678019393 tokens from its locked account 57bea511f28a9c0d44148c332826a9b9fb14f13c.lockup.near to a staking pool staked.poolv1.near

Read more about epochs changing here.

Last updated