2

Somewhat noob question:

I see the term storage cell talked about a lot on here (mostly regarding Mapping and Lazy), however I cannot find any documentation about it.

What exactly is a storage cell? Are they a set size? If so what is the size? Does the size vary based on individual pallet implementation? Is there any way to access the size of a storage cell in ink? What happens if a storage cell's size is exceeded? Is the data split across two cells instead?

I assume a storage cell is a record in a database on a node, is that correct?

Assuming storage costs are proportional to the number of records used in the db by a smart contract, it would be handy to know the size of the storage cells so I can optimise the smart contract storage accordingly.

1 Answer 1

2

TLDR: ink! storage documentation

To answer your questions:

Storage in ink! is organized as a key/value database. So for each unique key, you have one unique cell (which can contain a value). The values are SCALE encoded, and the maximum length of a value is defined by the pallet. If this value is exceeded, you will get a DispatchError, and the contract execution will be trapped (reverted). The default value in substrate/frame/contracts is 16 * 1024 bytes.

Your Answer

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

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