Export flat contract on compilation via Hardhat.
👾 Additional supplement to the official flatten command
npm install --save-dev hardhat-flat-exporter
# or
yarn add --dev hardhat-flat-exporter
And add the following to your hardhat.config.js
:
require("hardhat-flat-exporter");
Or, if you are using TypeScript, add this to your hardhat.config.ts:
import "hardhat-flat-exporter";
Configuration is optional.
module.exports = {
flattenExporter: {
src: "./contracts",
path: "./flat",
clear: true,
},
};
option | description | default |
---|---|---|
src |
folder path of the target contracts (relative to Hardhat root) | './contracts' |
path |
path to flat sol export directory (relative to Hardhat root) | './flat' |
clear |
whether to delete old flat sol files in path on compilation |
true |
The included Hardhat tasks may be run manually:
npx hardhat export-flat
# or
yarn run hardhat export-flat