I am new to Solidity and Web3.js. I created a contract and tested it using Remix. With Web3.js, I am able to get the contract instance if I know the address and query it and print the results on a web page.

But I want to query and get all the instances of a type of contract that is already created and list it on my HTML page. For this, I assume that I have to get the addresses of these instances. I will appreciate if anybody can provide pointers on how to go about doing this.

If this is not possible, I want to be able to create instances of contract from Web3.js without having to create it in Remix. Pointers for that will also be appreciated.

1 Answer 1


You can use a registry pattern, where each new instance add itself to a registry contract. Where you can query already deployed contracts.

Or a factory pattern where the factory creates each contract and keeps a list of deployed contracts.

  • Thank you @Ismael. With the Registry pattern, I will still have to keep track of the address of that one contract in an external store. Is there a way to query the BlockChain to get all contracts of a certain type or based on some search criteria like you would do with SQL? Jan 31, 2018 at 15:31

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.