1

I have a contract A that does nothing other than allowing to deploy contracts B and C in functions. Deployment of A exceeds gas limit. Seperate deployment of B and C work fine.

So my naive assumption seems to be wrong: it is much cheaper to provide the functions to A (which arent actually executed on deployment of A) instead of actually deploying B abd C e.g. in the constructor.

Can someone correct me/ give me the background? And maybe give me a hint on how to best deploy tree structures of contracts that depend on previously created ones?

Thanks in adance

1 Answer 1

0

From your description (no code) I think I can surmise what's probably happening.

The factories necessarily include the code of the contracts they deploy. They need to, so they have the bytecode to work with. Consequently, FactoryB contains ContractB and FactoryC contains ContractC.

If the factories themselves add minimal functions, they will be a little larger than the contracts they deploy, but not alarmingly so.

On the other hand, if there's a MegaFactory and it deploys both B & C (or more ...) then the size of this factory is going to larger than the sum of it's parts: B + C + ...

A solution to this problem is to have single-purpose FactoryB and FactoryC. You can then implement a MegaFactory using interface contracts that describe only the API for two "actual" factories. The MegaFactory will be able to dispatch jobs to FactoryB and FactoryC without containing all the bytecode of the contracts they deploy.

Hope it helps.

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.