# Testing Huff with Foundry

While Huff can be compiled through the command line tool, you can also use Foundry to test your code. Foundry (opens new window) is a blazing fast, portable, modular toolkit for Ethereum application development. Foundry enables you to easily compile your contracts and write robust unit tests to ensure that your code is safe. This is especially important for Huff contracts, where there aren't many automatic safety-checks on your code.

You can use the two together via the foundry-huff (opens new window) library.

# Utilizing Foundry-Huff

If you have an existing Foundry project, you can simply install the necessary dependencies by running:

forge install huff-language/foundry-huff

You also must add the following line to your foundry.toml file to ensure that the foundry-huff library has access to your environment in order to compile the contract:

ffi = true

You can then use HuffDeployer contract to compile and deploy your Huff contracts for you using the deploy function. Here's a quick example:

import { HuffDeployer } from "foundry-huff/HuffDeployer.sol";

contract HuffDeploymentExample {
    function deploy() external returns(address) {
        return new HuffDeployer().deploy("MyContract");
    }
}

For more information on how to use Foundry, check out the Foundry Github Repository (opens new window) and Foundry Book (opens new window).

# Using the Project Template

If you're looking to create a new project from scratch, you can use the project template (opens new window).

We go over using the project template in https://docs.huff.sh/get-started/project-quickstart/ (opens new window).