Storage Staking
When you deploy a smart contract to NEAR, you pay for the storage that this contract requires using a mechanism called storage staking.
In storage staking (sometimes called state staking), the account that owns a smart contract must stake (or lock) tokens according to the amount of data stored in that smart contract, effectively reducing the balance of the contract's account.
Coming from Ethereum?If you’re familiar with Ethereum’s pricing model, you may know that, like NEAR, the protocol charges a fee (called "gas") for each transaction. Unlike NEAR, Ethereum's gas fee accounts for the amount of data stored via that transaction. This essentially means that anyone can pay once to store permanent data on-chain. This is a poor economic design for at least two reasons: 1. The people running the network (miners, in the case of Ethereum 1) are not appropriately incentivized to store large amounts of data, since a gas fee far charged in the distant past can increase storage costs forever, and 2. The users of a smart contract are charged for the data they send to store in it, rather than charging the owner of the smart contract.
How does NEAR's design align incentives?
Storage-staked tokens are unavailable for other uses, such as validation staking. This increases the yield that validators will receive. Learn more in the economics whitepaper.
When do tokens get staked?
On each incoming transaction that adds data.
Let's walk through an example:
- You launch a guest book app, deploying your app's smart contract to the account
example.near - Visitors to your app can add messages to the guest book. This means your users will, by default, pay a small gas fee to send their message to your contract.
- When such a call comes in, NEAR will check that
example.nearhas a large enough balance that it can stake an amount to cover the new storage needs. If it does not, the transaction will fail.