[Solved] How to calculate storage rent?


Through a random chance, I managed to find out the name that the number ‘6695476875’ is referred to as, ‘Reserved for transactions’, (in gas, not tokens) as in the official wallet (wallet.near.org). God knows why it is reserved, neither docs.near.org, nomicon.io nor wiki.near.org have any info regarding this ‘reservation’ and this number is never mentioned in any RPC API method. This number is also never mentioned in ‘near-api-js’ lib, so I really have no idea if devs are even aware of it.
Anyway, since the title of this problem is ‘How to calculate storage rent’, the answer is something like this:

  1. You get account info from ‘query’ method of RPC API (here‘s the doc) and take the “storage_usage” value (this is the amount of bytes that your account takes up on the blockchain).
  2. You get protocol info from ‘EXPERIMENTAL_protocol_config’ method of RPC API (here‘s the doc) and take the “storage_amount_per_byte” value.
  3. You multiply the amount of bytes by the storage_amount_per_byte and add the magic 669547687500000000 number to it.

And the resulting number is the least amount of tokens that you must have at your account at any time.

I don’t know why it is a common practice to make lives of developers harder in blockchain industry, but this is a good example of such practice.

solved How to calculate storage rent?