Skip to content

This is demonstrates how much gas we can save from adopting different code styles

Notifications You must be signed in to change notification settings

kwamentw/GasBad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gas Saving Techniques

This repository is mainly to test any gas saving technique we see or here about to know how much gas we really save to know whether it is effective.

for.sol - contains gas optimization techniques for for loop

require.sol - contains gas optimization techniques for handling reverts i.e require & custom reverts

return.sol - checks how much gas spent with the way we return valies in function calls

variables.sol - checks how much gas the various initialization of variables coding styles cost

if.sol - contains the best gas optimizing way to write multiple conditions in an if 

swap.sol - checks how much gas you will save when using two different styles in swapping variables


bitwise.sol - contains bitwise gas optimizations for common arithmetic operations like /2 or *4

bitwiseAccessControl.sol - is a style of access control using bitwise operators i saw and i think its cool

Credits

  1. All the twitter accounts that tweet about Gas
  2. https://github.com/devanshbatham/Solidity-Gas-Optimization-Tips - inspired the bitwise.sol, swap.sol, 4th and 5th function of for.sol.

Usage

Build

$ forge build

Test

$ forge test

About

This is demonstrates how much gas we can save from adopting different code styles

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published