2

Following this tutorial: https://www.shawntabrizi.com/substrate/querying-substrate-storage-via-rpc/

we should have that a pallet named "Members" should have prefix "0xba7fb8745735dc3be2a2c61a72c39e78" (equals to TwoX128("Members"))

However when accessing the value of the running chain using the polkadot-ui I get "0x2ce461329fdf4be12bce01afc0af09bc"

Details

  • pallet name from metadata is obtained from api.rpc.state.getMetadata() with api being of type ApiPromise
  • twox128 is computed via @polkadot/util-crypto xxhashAsHex

1 Answer 1

1

After some inspection for the api.rpc.state.getMetadata(..) in the latest version of the MetadataV* type (currently MetadataV14) you can get the string used for the prefix from metadata.asLatest.pallets.storage.unwrap().prefix.toString() (clearly provided that metadata.asLatest.pallets.storage is not None)

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.