I have a base abstract contract which is inherited by 3 other contracts (all having the same interface). I am trying to use a factory contract to conditionally create instances of the derived contracts but the overall size of the factory is becoming too large (>24KB) on importing all 3 of them. I suspect it's because of the redundant code of base abstract contract which is common to all.

What would be the correct/best possible way to achieve this? Thanks

1 Answer 1


You may need to split the factory up, having one "parent" factory which does not import the contracts, but instead calls one of three factories for the kind of contract being deployed. Then the 3 individual factories each only import one of the contracts, and are only responsible for deploying that one kind of contract.

There may also be a way to take the common code and deploy it as a library and link to it, but this can get complicated and/or impossible/insecure. We'd recommend looking into the first option.

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.