A sequence of smart contracts to practice gas optimization. These are used as practice assignments for RareSkills.io and the Udemy Gas Optimization Course
There should be unit tests to ensure people aren't hardcoding solutions. These should pass if the logic is adhered to and not measure the gas cost. This is to let people know they didn't break things as they update the contract.
Contribute a new gas puzzle to the RareSkills.io repo. To qualify, your gas puzzle must:
Follow the same pattern as the ones in this repo
Inefficient code must be realistic and clean. The point is to teach developers how to make reasonable code great, not how to fix ugly code.
The gas target must require using a non-obvious trick or two, but should not require excessive and highly advanced optimization, unless explicitly marked as such. (See ERC165 for an example)
The problem should be realistic. Puzzles that are clearly useless like "discover if the calldata is a palindrome" won't be accepted.
However, solutions don't have to be safe or realistic. The point is to drill knowledge of the EVM.
For this bounty, only one solution will be accepted.
I am having some trouble trying to optimize the Distribute contract. I believe that I need to do something about the transfer functions. I tried putting the 4 transfers in a for loop and also defining a local memory array that copies the contributors storage array, so that it does not get cold access for each element. But nothing of that worked. Could you give some tip that can help me solve this challenge? Thank you