-
Notifications
You must be signed in to change notification settings - Fork 24
Storage
Izek edited this page Feb 9, 2022
·
1 revision
NEAR uses storage staking which means that a contract account must have sufficient balance to cover all storage added over time. This standard provides a uniform way to pass storage costs onto users. It allows accounts and contracts to:
- Check an account's storage balance.
- Determine the minimum storage needed to add account information such that the account can interact as expected with a contract.
- Add storage balance for an account; either one's own or another.
- Withdraw some storage deposit by removing associated account data from the contract and then making a call to remove unused deposit.
- Unregister an account to recover full storage balance.
Prior art:
- A previous fungible token standard (NEP-21) highlighting how storage was paid for when increasing the allowance of an escrow system.
To show the flexibility and power of this standard, let's walk through two example contracts.
-
A simple Fungible Token contract which uses Storage Management in "registration only" mode, where the contract only adds storage on a user's first interaction.
- Account registers self
- Account registers another
- Unnecessary attempt to re-register
- Force-closure of account
- Graceful closure of account
-
A social media contract, where users can add more data to the contract over time.
- Account registers self with more than minimum required
- Unnecessary attempt to re-register using registration_only param
- Attempting to take action which exceeds paid-for storage; increasing storage deposit
- Removing storage and reclaiming excess deposit