0

Looking to write a call that could return all the contract addresses of ink contracts matching a code hash of the contract via RPC.

What would be the best way to go about getting the list of contract instances matching the hash?

Thanks.

2
  • What types of contracts? I presume ink using the contracts pallet or evm & frontier, but please update your question to be more explicit?
    – Nuke
    Sep 17, 2022 at 2:31
  • You're correct, they are ink contracts. Sep 17, 2022 at 4:12

1 Answer 1

2

The pallet_contracts has the storage ContractInfoOf (see in the code) which is a mapping of the contract info (that includes the code hash) associated with a given account.

You can query all the elements stored here and get all the account Ids that matches your hash code.

An example of the query using PolkadotJS UI:

enter image description here

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.