1

I'm writing a smart contract where one of the functions deploys a payment splitter contract that inherits from OZ PaymentSplitter.sol. I'm doing something like:

function splitterFactory(address[] memory payees, uint256[] memory shares_) private {
splitterContract _splitterContract = new splitterContract(payees, shares_);
}

when this function is marked as internal or private, it compiles just fine. If it's public or external, my smart contract is too big and does not compile. using hardhat-contract-sizer i can see that by changing this single function from internal to public adds over 10 kb to my final, most derived contract

my question is, is this normal? is there any tricks to fix this? does cloning or proxies take up less space? should I just deploy a contract factory separately on its own? I tried using solidity optimizer to no success.

Thanks! Nolan

1 Answer 1

0

maybe try the --optimize flag, along with --optimize-runs=25. this usually gets rid of the size errors for me.

2
  • 1
    thanks, I tried the optimizer, but ill try 25 specifically. I specify it in the hardhat.config file, do I need to add the flag every time I compile? Dec 8, 2021 at 16:39
  • I don't know much about hardhat, but I think if you do it in the config file, it'll automatically do it every time. Dec 11, 2021 at 3:18

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.