Giter VIP home page Giter VIP logo

huff-puzzles's Introduction

huff-puzzles by RareSkills

A series of puzzles that go from very easy to more difficult so that you can have a hands-on introduction to the huff language and learn EVM bytecode while doing it.

Pre-requisites

Make sure you've installed the Huff Compiler as outlined in the Huff Docs.

TLDR:

curl -L get.huff.sh | bash

then:

 huffup

To verify your installation, run huffc --help. This should print a list of available commands for the huff compiler cli.

Installation

To install dependencies, run:

forge install

How to play

Go to Return1.huff in the src folder and edit it as follows

#define macro MAIN() = takes(0) returns(0) {
    // store 1 in memory at offset 0
    0x01            // [1]
    0x00            // [0, 1]
    mstore          // []

    // return 1
    // return 32 bytes of memory starting at offset 0
    0x20            // [32]
    0x00            // [0, 32]
    return          // []
}

Then run the test with

forge test -vvv --mc Return1Test

You should see something like this

Running 1 test for test/Return1.t.sol:Return1Test
[PASS] testReturn1() (gas: 5358)
Test result: ok. 1 passed; 0 failed; finished in 4.56s

Suggested order for other exercises

More resources

Contributors

huff-puzzles's People

Contributors

0xrishabh avatar amadimichael avatar calvbore avatar erhant avatar eugenioclrc avatar jayrajrodage avatar jeffreyscholz avatar jesserc avatar justefg avatar maddiaa0 avatar nicobevilacqua avatar rareskills avatar sabnock01 avatar sashik-eth avatar thomaswos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

huff-puzzles's Issues

Add more cases to `KeccakTest`

More test cases should be added to KeccakTest, such as testing for empty calldata & a longer string.

function testKeccak() public /**bytes memory data*/ {
   _testKeccak(hex"abcd");
   _testKeccak(hex"abcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890");
   _testKeccak("");
}

function _testKeccak(bytes memory data) internal {
   bytes32 expectedHash = keccak256(abi.encode(data));

   (bool success, bytes memory res) = keccak.call(abi.encode(data));
   require(success, "call failed");
   assertEq(
      expectedHash,
      abi.decode(res, (bytes32)),
      "huff keccak hash != expectedHash"
   );
}

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.