0

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

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, privacy policy and cookie policy

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