1

I have a scenario where I have to enter all values of a storage in drop down through Polkadot JS UI.

Suppose I have a pallet TestPallet and an extrinsic rate. There are two storage Items and Rating.

If a user selects TestPallet >> rate, I want to show all the items stored in Items so that user can select and rate.

In Items, items are stored with an id. So when user selects any item, I can store in Rating with ItemId.

Can someone please help me to provide the solution? Thanks in advance.

1 Answer 1

2

It is possible to retrieve a list of all the keys and entries from a maps and double-maps with: .entries(<args>): [StorageKey, Type][].

An example in your case will be more or less like this:

const items = await api.query.testPallet.items.entries();

And this will be an array of key-values.

See in this previous StackExchange question an example to get all contracts: How to get a list of all the smart contract account ids and WASM blobs on a parachain

And see an example in the PolkadotJS docs.

2
  • sorry I still didn’t get my solution. How can I display list in Polkadot Js UI on extrinsic page?
    – Boleng
    May 22 at 20:05
  • Ahh sorry, In the current PolkadotJS UI this is not possible, but you can implement that if you have a custom UI using the polkadot-js library
    – Alex Bean
    May 23 at 8:27

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.