I am new to programming with solidity and ethers.js and web3.js. I have created a factory contract with solidity as described in this blog post: factory pattern. I am now working on the front end, web3-react and ether.js. I see that ether.js has contract factory API, but it seems, if understand correctly, that ether.js allows you to deploy the "child" contracts directly, thus making a factory contract in solidity redundant.

The problem is that the factory contract in solidity serves two purposes one to deploy child contracts and two to track the deployed contracts, whereas, ether.js only deploys contracts.

How does one handle tracking, or more specifically mapping account to deployed contract address with ethers.js? Does one create a separate contract for tracking only, and then send an update that contract each time a new contract is deployed by the factory? Or, are there any other recommended patterns to solve this?

1 Answer 1


The Factory pattern you are seeing in the block post is distinct from the ethers.js ContractFactor (docs)

  • ethers.js Contract Factory: this is a basic concept that it allows to deploy arbitrary smart contracts to ethereum network using a wallet. It needs json abi and bytecode you usually get from solidity compiler along with a signer (can be ethers.Wallet or Metamask or other compatible signers)
  • Solidity's Contract Factory: This is a smart contract architecture which enables deploying child smart contracts through parent smart contract (e.g. Uniswap Pairs). But it requires you to initially deploy the parent contract using something like ethers.js's ContractFactory or web3.js. Then you can use the createChildContract function to deploy further contracts on chain.
  • I understand that what is shown in the blog post is distinct from the ethers.js ContractFactory. Does one replace the other? And, if it there is no factory contract in Solidity, just the contract to be deployed, then how does one track the deployed contracts? Apr 30, 2021 at 19:44
  • You can emit some event with the address of the deployed contract or track in the state. After your createChildContract tx is confirmed, just query the information. However, if you use CREATE2 (e.g. like how UniswapV2 does), then you can deterministically compute the contract address using input parameters. You can also see ethereum.stackexchange.com/questions/760/… May 1, 2021 at 22:37

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.