In the huff docs we see examples using the include keyword, such as:

#include "huffmate/utils/Errors.huff"

#define macro ADD_TWO() = takes (2) returns (1) {
    // Input Stack:  [a, b]
    add           // [a + b]
    // Return Stack: [a + b]

#[calldata("0x0000000000000000000000000000000000000000000000000000000000000001"), value(0x01)]
#define test MY_TEST() = {
    0x00 calldataload   // [0x01]
    callvalue           // [0x01, 0x01]
    eq ASSERT()

But it doesn't provide docs on how these work. How do the imports work?

1 Answer 1


It works with foundry remappings, so it's the same way you'd import into a solidity file but replacing "import" with "include".

#include "path/to/file.huff"

It doesn't support named imports

It basically pastes everything from the file you imported into the file Importing it.

At compile time, huffc flattens the code, it throws an error if there are macros with duplicate names

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.