Coder Social home page Coder Social logo

iampukar / solidity-gas-optimization Goto Github PK

View Code? Open in Web Editor NEW
10.0 1.0 1.0 25 KB

An awesome list of gas optimization techniques for smart contracts, with their relevant Proof of Concepts tested using Foundry.

License: MIT License

Solidity 100.00%
foundry gas-optimization smart-contract-security smart-contracts-audit solidity solidity-gas-optimization solidity-security

solidity-gas-optimization's Introduction

Getting Started

curl -L https://foundry.paradigm.xyz | bash
foundryup
brew install libusb

Running Test

  • Test all files

      forge test
    
  • Test all files with traces

      forge test -vvvv
    
  • Test for individual file

      forge test --match-path test/Arithmetic.t.sol
    
  • Test for individual files with traces

      forge test --match-path test/Arithmetic.t.sol -vvvv
    

Gas Optimization

Title Guide Contract Proof of Concept
Arithmetic & Bitwise Operators Guide Contract PoC
Public vs External Guide Contract PoC
Default Initialization (x) Guide Contract PoC
Revert Strings Guide Contract PoC
Redundant Checks Guide Contract PoC
Nested If Statements Guide Contract PoC
State Variable vs Local Variable Guide Contract PoC
Packing Variables Guide Contract PoC
Data Types Guide Contract PoC
Addition Guide Contract PoC
Garbage Collection Guide Contract PoC
Swap Guide Contract PoC
Call Data vs Memory Guide Contract PoC
Immutable Guide Contract PoC
Solidity Version Guide
Unsigned Integer Comparision Guide Contract PoC
Boolean Guide
Custom Errors Guide Contract PoC
Optimization Guide
Use of Library Guide
String vs Bytes32 Guide Contract PoC
Multiple Require Guide Contract PoC
Loop Post Condition Guide Contract PoC
Dead Code Guide
Short Circuiting Guide

References

  1. https://betterprogramming.pub/how-to-write-smart-contracts-that-optimize-gas-spent-on-ethereum-30b5e9c5db85?gi=227bef2ca134
  2. https://mudit.blog/solidity-gas-optimization-tips/
  3. https://blog.polymath.network/solidity-tips-and-tricks-to-save-gas-and-reduce-bytecode-size-c44580b218e6
  4. https://gist.github.com/hrkrshnn/ee8fabd532058307229d65dcd5836ddc
  5. https://medium.com/coinmonks/8-ways-of-reducing-the-gas-consumption-of-your-smart-contracts-9a506b339c0a
  6. https://ethereum.stackexchange.com/questions/28813/how-to-write-an-optimized-gas-cost-smart-contract
  7. https://forum.openzeppelin.com/t/a-collection-of-gas-optimisation-tricks/19966
  8. https://medium.com/coinmonks/8-ways-of-reducing-the-gas-consumption-of-your-smart-contracts-9a506b339c0a

solidity-gas-optimization's People

Contributors

iampukar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

ololade97

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.