Use calldata Instead of Memory for Function Parameters
The "calldata" keyword is used for data that is sent as part of the transaction and is not stored in the contract's state. It is read-only, and its main advantage is that it is cheaper in terms of gas costs compared to "memory".
So, by changing "memory" to "calldata" in the function parameters, we can optimize the contract for lower gas usage.
Gas optimization:
Memory:
Running 1 test for test/uint/OnlyDistributorTest.t.sol:DistributionTest
[PASS] testCallingdistributeWillFail() (gas: 15945)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.69ms
Running 1 test for test/integration/ProxyFactoryTest.t.sol:ProxyFactoryTest
[PASS] testRevertsIfCalledByNonOwnerdistributeByOwner() (gas: 239325)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 6.78ms
Ran 2 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)
Calldata:
Running 1 test for test/uint/OnlyDistributorTest.t.sol:DistributionTest
[PASS] testCallingdistributeWillFail() (gas: 14723)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 1.61ms
Running 1 test for test/integration/ProxyFactoryTest.t.sol:ProxyFactoryTest
[PASS] testRevertsIfCalledByNonOwnerdistributeByOwner() (gas: 238925)
Test result: ok. 1 passed; 0 failed; 0 skipped; finished in 4.74ms
Ran 2 test suites: 2 tests passed, 0 failed, 0 skipped (2 total tests)
Manual
To resolve this issue, you should change the "memory" keyword to "calldata" in the function parameters
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.