2

StorageKey keyword mentioned in the RPC substrate docs and polkadotJS RPC API docs https://polkadot.js.org/docs/substrate/rpc#getkeyskey-storagekey-at-blockhash-vecstoragekey

How to get this StorageKey?

2 Answers 2

3

You can also use the apps UI to create keys, generally if these are single items this is a quick approach. In the apps UI via the storage page, you can see the encoded keys based on the input parameters (along with a breakdown on the right as to which component is due to which part)

system.account query

Additionally (and this is most probably not applicable for your case, however I'm including it here for future reference), you can also do it programatically via the JS API.

console.log(
  // each api.query.<module>.<method> has .key exposed that
  // generates an encoded storage key
  api.query.system.account.key(
    // any parameters that you would need
    '1363HWTPzDrzAQ6ChFiMU6mP4b6jmQid2ae55JQcKtZnpLGv'
  )
);

The above would output the same details as found in the apps UI screenshot above, i.e 0x26aa...2f28 which is the key for that specific account at this storage location.

1
  • 1
    thank you so much @Jaco. You have been a really supportive member of the community. I really appreciate your efforts :)
    – muddlebee
    Commented Jul 15, 2022 at 15:01
2

Great question!

If you have a prefix of a storage key that you are looking for, you can specify in the first argument like so:

Note that if you specify 0x you will get all the keys!

If you want to know how the storage keys are created I recommend reading:

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.