3

When developing ink smart contracts, I've often seen a Storage Deposit charge. What is this, and how does it relate to contract storage?

My guess is it's a charge related to the size of the contract's storage, so the larger the data store for a contract the higher the gas fee per tx for that contract. Is that correct? If so, how is the fee decided?

1 Answer 1

2

The storage deposit is the payment for the contract storage.

It is used to pay for onchain storage for a contract, reduce storage bloat, and protect against spamming or a DOS attack.

There is also a storage deposit limit which is the maximum storage deposit that can be charged from the caller for the storage consumed.

Edit by @goastler on 19/08/2023: I've gone through the code linked above trying to work out how the storage deposit is charged. Here's the struct representing the contract. Whenever a contract's storage is changed, the difference in the size from before and after is charged to the caller (I believe this can be a refund if the contract storage has shrunk in total) - see here and here. This is taken out of the gas for the transaction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.