Giter Site home page Giter Site logo

nishuzumi / gas-puzzles Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rareskills/gas-puzzles

0.0 1.0 0.0 5.98 MB

A sequence of smart contracts to practice gas optimization. These are used as practice assignments for RareSkills.io and the Udemy Gas Optimization Course

Home Page: https://rareskills.io

JavaScript 61.02% Solidity 38.98%

gas-puzzles's Introduction

RareSkills Gas Puzzles

If you want to learn about gas optimization, take the Udemy gas optimization course!

Puzzles that are ready for you

  • Distribute (hard)
  • Array Sum (easy)
  • Mint150 (hard)
  • ERC165 (low level programming required)
  • Escrow
  • EscrowV2
  • Mint
  • Presale
  • Require (easy)
  • Staking

Contributors

DO NOT COMMIT SOLUTIONS, BE SURE TO PUT ANSWERS IN contracts/contracts_optimized to ensure they fall into the .gitignore

Players

Your goal is to optimize the contracts such that they reach the target efficiency.

Rules

  • you may not change the optimizer level
  • you may not change the solidity version
  • you may refactor functionality as long as you don't break the business logic
  • you may make reasonable assumptions about what variable sizes are necessary to get things done
  • you may remove unnecessary or redunant logic (some have been intentionally added)
  • because making functions payable is a controversial optimization, you do not need to make functions payable to reach the gas target unless the function needs to be payable to fulfill its business logic

Testing

As mentioned above, optimized contracts should be created in their own sub-folder to prevent commiting them publicly.

The file structure should look similar to this:

- GasPuzzles
  |_
    contracts
    |_
      contracts_optimized
    | |_
    |   ArraySum.sol
    |   Distribute.sol
    |   ..
    |   ...
    |
    ArraySum.sol
    Distribute.sol
    ..
    ...

Within the contracts that are optimized be sure to follow the following naming convention to ensure tests run smoothly:

contract OptimizedArraySum {

...

contract OptimizedDistribute {

...
npx hardhat test
npx hardhat test test/ArraySum
npx prettier --write *

gas-puzzles's People

Contributors

burke-md avatar jeffreyscholz avatar jesperkristensen58 avatar rareskills avatar remedcu avatar

Watchers

 avatar

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.