hardhat-merger
v1.0.2
Published
Plugin for Hardhat to generate merged smart contracts in Solidity
Downloads
4
Maintainers
Readme
Hardhat Merger Plugin
This is a plugin for Hardhat that allows you to generate merged smart contracts in Solidity. The plugin provides a seamless way to combine multiple Solidity files into a single output file, making it easier to manage and deploy your contracts.
Installation
To use this plugin, follow these steps:
- Ensure you have Node.js installed on your machine.
- Install Hardhat by running
npm install --save-dev hardhat
. - Install the Hardhat-Abigen plugin by running
npm install --save-dev hardhat-merger
.
Usage
To use the plugin, import it in your JavaScript or TypeScript file as follows:
JavaScript
require("hardhat-merger");
TypeScript
import "hardhat-merger";
Configuration
The plugin supports custom configuration options, which can be specified in your Hardhat configuration file (hardhat.config.js
or hardhat.config.ts
). Here is an example configuration for the merger
section:
JavaScript
module.exports = {
// ...other configuration options...
merger: {
outDir: "merged", // The output directory for the merged contracts (default: "merged")
inDir: "contracts", // The input directory containing the individual contracts (default: "contracts")
includeContracts: ["*"], // An array of contract patterns to include in the merge (default: ["*"])
excludeContracts: [], // An array of contract patterns to exclude from the merge (default: [])
},
};
TypeScript
import { HardhatUserConfig } from "hardhat/config";
const config: HardhatUserConfig = {
// ...other configuration options...
merger: {
outDir: "merged", // The output directory for the merged contracts (default: "merged")
inDir: "contracts", // The input directory containing the individual contracts (default: "contracts")
includeContracts: ["*"], // An array of contract patterns to include in the merge (default: ["*"])
excludeContracts: [], // An array of contract patterns to exclude from the merge (default: [])
},
};
export default config;
Make sure to adjust the configuration according to your project's needs.
Generating merged contracts
To generate smart contracts, run the following command:
npx hardhat merger
This will generate the merged contracts in the specified outDir
directory.
License
This plugin is open-source and available under the MIT License. Feel free to use, modify, and distribute it as per the terms of the license.
Note: Please ensure that you have a backup of your contracts before using the Hardhat Merger plugin. While every effort has been made to ensure the reliability and accuracy of the plugin, it is always recommended to perform thorough testing and review before deploying merged contracts in a production environment.
I hope this plugin simplifies your development workflow by automatically generating merged smart contracts in Solidity. If you encounter any issues or have suggestions for improvements, please open an issue. Contributions are also welcome!