Skip to content

hardhat-foundry

This plugin provides compatibility between Hardhat and Foundry-based projects by automatically loading Solidity remappings generated by forge, including those installed with npm.

When to use this plugin

This plugin is intended to be used when your project or your dependencies depend on remappings generated by Foundry, instead of declaring them in a remappings.txt file.

Installation

First, you need to make sure you have installed Foundry by following the Foundry installation guide.

Then, install the plugin by running the following command:

Terminal window
npm install --save-dev @nomicfoundation/hardhat-foundry

In your hardhat.config.ts file, import the plugin and add it to the plugins array:

import { defineConfig } from "hardhat/config";
import hardhatFoundry from "@nomicfoundation/hardhat-foundry";
export default defineConfig({
plugins: [hardhatFoundry],
});

Usage

You only need to install the plugin and Hardhat will be able to resolve Solidity remappings for Foundry-based packages, including those installed with npm.