Package Exports
- hardhat-packager
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hardhat-packager) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Hardhat Packager

Hardhat plugin for preparing the contract artifacts and the TypeChain bindings for registry deployment.
Description
This plugin builds on top of TypeChain's plugin to prepare your contract artifacts and TypeChain bindings for being deployed to a package registry (e.g. npmjs.org). More specifically, it deletes all artifacts and bindings that are not in an allowlist of contracts, minifying the folder structure in the process.
Installation
First, install the plugin and its peer dependencies. If you are using Ethers or Waffle, run:
yarn add --dev hardhat-packager typechain @typechain/hardhat @typechain/ethers-v5
Or if you are using Truffle, run:
yarn add --dev hardhat-packager typechain @typechain/hardhat @typechain/truffle-v5
Second, import the plugin in your hardhat.config.js
:
require("@typechain/hardhat");
require("hardhat-packager");
Or if you are using TypeScript, in your hardhat.config.ts
:
import "@typechain/hardhat";
import "hardhat-packager";
Required plugins
Tasks
This plugin adds the prepare-package task to Hardhat:
Prepares the contract artifacts and the TypeChain bindings for registry deployment
Configuration
This plugin extends the HardhatUserConfig
object with an optional packager
object. This object contains one field,
contracts
. This is an array of strings that represent the names of the smart contracts in your project. The plugin
uses this array as an allowlist for the artifacts and the bindings that should be kept for registry deployment.
An example for how to set it:
module.exports = {
packager: {
contracts: ["MyToken", "ERC20"],
},
};
Usage
To use this plugin you need to decide which contracts you would like to be part of the package deployed to the registry. Refer to the configuration section above.
Then, run it like this:
yarn hardhat prepare-package
Go look what you have in the artifacts
and the typechain
folders.
Tips
- You may want to add the
artifacts/**/*.json
,contracts/**/*.sol
andtypechain/**/*.d.ts
globs to the files field in yourpackage.json
file. - You may want to blocklist some files, such as test contracts, which you can do with an .npmignore file.
- See how the plugin is integrated in hifi-protocol.
License
The plugin is released under the WTFPL License.