2

There are some aspects of ink! contract storage and data access that I cannot find the answers to in the documentation or by experimentation. Here are my questions...

  1. Is it true that there can be multiple instantiations of the same contract existing simultaneously?

  2. Is it true that any account on the blockchain system can interact with any and all instantiations of a given contract?

  3. Contract storage means that data structures defined under the #[ink(storage)] attribute are stored somehow locally "in" the contract, as opposed to in blocks on the chain. (exactly where is this being stored?)

  4. Contract storage is set to some finite limit when you deploy the contract (or is it set when you instantiate it? )

  5. Does each instantiation have its own storage? (what is the limit on storage per instantiation? and what happens when you run out of storage on the contract instantiation?)

  6. Topics (as defined in Events) are searchable. (but where and how does one search on those topics?)

Thanks!!

1 Answer 1

2

There can be multiple instances of one contract.

Any account can interact with any smart contract on the blockchain, but only with its messages (public API). So if a contract has no [ink(message)], other accounts can not mutate its state (except for sending balance to this contract).

The state of the contract (a.k.a. the contract storage) is stored on the blockchain.

The contract will be given a specific AccountId upon the instantiation. Each instance of a contract has its own storage.

About the storage limitations, ink! stores all the contract data under specified storage keys, and panics if the encode length of value exceeds the configured maximum value length of a storage entry. The keys are hashed to a 32-byte hash (which leaves us with 2^256 possible storage entries - about this I am not 100% sure, I am assuming based on this file and ethereum knowledge).

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.