# Huff Project Template
Huff has a project template (opens new window) to make it easier to get started writing Huff contracts!
# Using the Template
After navigating to https://github.com/huff-language/huff-project-template, you can click the Use this template (opens new window) button on the top right of the repository to create a new repository containing all of the template's code.
Once you've cloned and entered into your repository, you need to install the necessary dependencies. In order to do so, simply run:
forge install
Then, you can build and/or run tests with the following commands:
forge build
forge install
Inside the template, there is a contract in the src/
directory (the default location for huff contracts) called src/SimpleStore.huff
. This contract demonstrates a simple contract to set and get values stored in the contract, with the functions being (as defined by the function annotations at the top of the contract):
function setValue(uint256);
function getValue() view returns (uint256);
Inside the test/
directory, there are tests for the src/SimpleStore.huff
contract in test/SimpleStore.t.sol
. Since Foundry (opens new window) doesn't natively support compiling huff code, huff projects have to use the foundry-huff (opens new window) library to be able to compile huff code using forge
commands.
NOTE: In order to compile huff code, foundry-huff behind the scenes need the huff compiler (opens new window) to be installed.
Returning back to our test contract test/SimpleStore.t.sol
, we can run the following command to run all tests: forge test
.
# Other Template Features
Once you have created a new repository from the project template (opens new window), there are a few things to note before digging in and writing your huff contracts.
The foundry.toml (opens new window) file located in the root of the project template, contains the configuration for using the forge
toolchain.
Inside ./.github/workflows (opens new window) there is a github action file that will run CI using the Foundry toolchain (opens new window) and the huff-toolchain (opens new window).