gas-optimizations icon indicating copy to clipboard operation
gas-optimizations copied to clipboard

List of smart contract optimizations in solidity

Results 13 gas-optimizations issues
Sort by recently updated
recently updated
newest added

I believe the example for this optimization is not completely correct. Immutable should be used when the state variable is assigned in the constructor. If it is directly assigned in...

Should add a section on this to https://github.com/kadenzipfel/gas-optimizations/blob/main/gas-saving-patterns/short-circuiting.md with this to leave the reader with a fully optimized statement e.g. use ``` if (condition) { if (anotherCondition) { ... }...

enhancement

for technical gas saving patterns, e.g. https://github.com/KadenZipfel/gas-optimizations/blob/main/gas-saving-patterns/optimal-comparison-operator.md, in which the pattern works because of a solidity compilation gotcha, the mechanism in which gas is saved should be better detailed, e.g....

enhancement

Each gas optimization should have this information: - further knowledge links to understand why that change improves gas usage - `forge snapshot` to compare A/B testing. How much gas are...

some things that can be added: - use selfbalance opcode instead of address(this).balance - use iszero opcode instead of if(x) - https://twitter.com/clemlak/status/1521973218864771073?s=20&t=Bw97nieWjOAs4O2x2Kr8Tg - etc

using https://rust-lang.github.io/mdBook/

documentation

in general, do while loops are cheaper than for loops. as long as the loop is must run at least once, do while is preferred over for loops

enhancement

we should make sure we have both: - clear examples, and - before and after gas benchmarks for every gas saving pattern

enhancement

outline usage of bit-packing using uints directly

enhancement