As far as I know, there are 2 ways of deploying a smart contract: normal deployment using an Ethereum address or through Singleton Factory smart contract.

When to use the Singleton Factory smart contract to deploy smart contracts? and what are the benefits of doing so in comparison with the normal deployment?

  • singleton factory follows EIP:2470 protocols , you can also write factory Contract for deployment of other smart contracts
    – Garampapa
    Aug 14, 2023 at 7:59

1 Answer 1


Not sure if there is 1 correct answer to this one.

Personally I started using a singleton factory (there are different ones out there) for the Safe, because we wanted to enable everyone to deploy the contracts to the same address (e.g. on a local network).

But this is not the only advantage. By using such a factory the contract address itself is proof the code (at least in most cases ... there are ways around it). Which makes it easy to verify that a contract is the same across networks, as you only have to compare addresses. Also when your contract is the implementation (formerly often called master-copy) contract for a Proxy contract setup, this also provides an additional layer of security as this contract could be redeployed in case of an unwanted selfdestruct (see Parity case).

In cases where you want more individual instance of your contract, instead of one singleton, I would say using the normal deployment flow, make more sense.

Note: The Singleton Factory relies on a presigned transaction that does NOT use replay protection. It is not possible to use this transaction on all networks, as some require replay protection (e.g. Avalanche and Optimism).

Edit (Follow up on "there are ways around it"):

The singleton factories use the create2 opcode to make the deployment as deterministic as possible. In this case the address of the new contract depends on the factory address, the deployment code and a salt.

It is important to understand how the deployment code is used. Normally the deployment code runs the constructor, loads the "runtime" code into memory and then returns the "runtime" code so that it is stored in the blockchain (here a nice blog post on this).

But it is possible to build the deployment code in a ways that it loads the code from another contract where the code could be stored in a variable that can be changed. Therefore the same deployment code would generate different runtime code. So the address would be the same but the code would differ.

  • Can you share some more information about "ways around it"?
    – Peter
    Jan 5, 2022 at 4:15
  • 1
    I adjusted my answer to include this
    – Richard
    Jan 5, 2022 at 8:54
  • 1
    Here a repo that has a factory for the "way around it": github.com/0age/metamorphic
    – Richard
    Jan 5, 2022 at 22:27

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.