Use assembly for math instead of Solidity. You can check for overflow/underflow in assembly to ensure safety. If using Solidity versions < 0.8.0 and you are using Safemath, you can gain significant gas savings by using assembly to calculate values and checking for overflow/underflow.
//Without assembly
| src/gas.sol:Contract0 contract | |||||
|---|---|---|---|---|---|
| Deployment Cost | Deployment Size | ||||
| 40693 | 234 | ||||
| Function Name | min | avg | median | max | # calls |
| addTest | 308 | 308 | 308 | 308 | 1 |
// With assemebly
| src/gas.sol:Contract1 contract | |||||
|---|---|---|---|---|---|
| Deployment Cost | Deployment Size | ||||
| 37087 | 216 | ||||
| Function Name | min | avg | median | max | # calls |
| addAssemblyTest | 263 | 263 | 263 | 263 | 1 |
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.