6

I have a very basic question - ink! now has a Mapping struct for key-value pairs. It seems it does not implement the Iterator trait?

3

2 Answers 2

7

There is no way to iterate over a Mapping from a contract. We intent to implement this functionality soon. For more information check out this issue: https://github.com/paritytech/substrate/issues/11410

If you try to iterate over a mapping off chain (from a UI for example) you could use the childState_getKeys RPC to list the keys of the child trie used by the contract in question.

0

There are any alternatives for HashMap today Mapping that developers can use and have possibility to iterate?

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.