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.
Substrate and Polkadot Stack Exchange is a question and answer site for developers building blockchains with the Substrate SDK. It only takes a minute to sign up.
Sign up to join this communityLooking 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.
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: