'How to avoid oversized factory contracts in solidity
I have a large contract which I managed to reduce in size to just under the size limit using libraries, etc. and it is now about 21K. Now I want to make a on-chain factory for this large contract
The problem is even though the factory contract contains nothing but a "makeFoo()" function, and a constructor the factory contract size is over 25K and can't be deployed.
All that's in the factory contract is something like this:
contract FooFactory {
address private _adminAddress;
function makeFoo(string memory name, string memory symbol) public returns(address) {
Foo newFoo = new Foo(name, symbol, msg.sender, _adminAddress);
return address(newFoo);
}
constructor(address adminAddress_) {
_adminAddress = adminAddress_;
}
}
Is there any other way besides "new" to "clone" a contract that's already deployed to the blockchain that doesn't result in the size of the factory contract to be 115% of the size of any contract upon which it calls "new"?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
