Managing EVM (Ethereum Virtual Machine) bytecode frequently demands a solid grasp of bitwise operations, including &
, |
, <<
, >>
, ^
and ~
. This collection of challenges draws significant inspiration from the RareSkills Huff Puzzles. In addition to providing a practical introduction to the Huff language, the tasks within this repository serve to enhance comprehension of bitwise operations in the context of Ethereum development.
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.
To install dependencies, run:
forge install
Go to GetBitAt.huff in the src folder and edit it as follows
#define macro MAIN() = takes(0) returns(0) {
// your Huff code goes here
}
Then run the test with
forge test -vvv --mc GetBitAt
You should see something like this
Running 1 test for test/GetBitAt.t.sol:GetBitAt
[PASS] testGetBitAt() (gas: 5358)
Test result: ok. 1 passed; 0 failed; finished in 4.56s
- Huff Documentation 🐴
- Bitwise Operations Tutorial (the assignments follow this tutorial)
- Evm codes
- Huff Console.log