I am writing a factory contract in solidity. I want to be able to add some more contracts to be deployed by the factory after it has been deployed.

I thought sending the contract's source code to my factory. Stock it in a mapping with a custom key. Then using a contract's function with the key in order to deploy a new contract from the new type. Is it only possible please ?

1 Answer 1


You can't do this with source code, because the contract would have no way to compile that code.

But you can do it with compiled bytecode:

bytes memory bytecode = ...;
assembly {
    contractAddress := create(value, add(bytecode, 0x20), mload(bytecode))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.