I am trying to clone my contract by using Clones.sol from OpenZeppelin. The cloning procedure is successful, although I cannot pass them my desired arguments which should be provided for construction function.

Does anyone know how can I overcome this issue?

  • I think it is not possible.
    – Majd TL
    Commented Nov 4, 2021 at 10:25

1 Answer 1


This is normal.

A deployed smart contract runtime bytecode does not include constructor code (see the constructor caveat).

In Solidity, code that is inside a constructor or part of a global variable declaration is not part of a deployed contract’s runtime bytecode. This code is executed only once, when the contract instance is deployed. As a consequence of this, the code within a logic contract’s constructor will never be executed in the context of the proxy’s state. To rephrase, proxies are completely oblivious to the existence of constructors. It’s simply as if they weren’t there for the proxy.

Therefore, you cannot pass any parameters to a constructor, as there is no constructor when you use clone.

What you need to do is use an initializer like in the link that I mentioned above and call that initializer just after cloning. Basically, your constructor becomes the initializer function.

Switch to openzeppelin-contracts-upgradeable for your clonable implementations. And make use of the initializer modifier to protect your "constructor".


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.