Question
Answer and Explanation
Hardhat Ignition is a plugin for Hardhat that introduces a new approach to deploying smart contracts, effectively replacing the traditional 'scripts' folder for deployment logic. Instead of using imperative scripts written in Javascript or Typescript, Ignition uses a declarative approach where you define the desired state of your deployments. Here’s what that means:
1. Declarative Deployments: With Ignition, you create "modules" that describe how your contracts should be deployed. You specify the contracts, their constructor arguments, and any dependencies between them. Ignition then takes care of the execution plan to bring the desired state of deployments.
2. Modularity: Deployments are organized into modules, enhancing code maintainability and readability. This makes it easier to understand complex deployment workflows. You can also reuse modules across different environments.
3. Dependency Management: Ignition automatically resolves dependencies between contracts. If one contract requires another to be deployed first, Ignition handles this intelligently. This simplifies the deployment of interconnected smart contract systems.
4. Built-in State Tracking: Ignition tracks the deployment progress and state, allowing for incremental deployment updates. You can resume deployments from where they left off. This feature is helpful during development and testing when redeployments are frequent.
5. Simplified Configuration: The configuration is abstracted to declarative modules, which means you write less complex, error-prone scripting code. This reduces the chances of mistakes during the deployment process. Instead of writing manual deployment scripts, you define your desired state, and Ignition handles the orchestration.
6. Replaces traditional ‘scripts’ folder: The traditional ‘scripts’ folder in Hardhat is used to house deployment scripts written using JavaScript or Typescript. With Ignition, those scripts are no longer needed. Instead, the main entry point of the deployment process becomes the modules you define with Ignition. This leads to a clearer separation of concerns: module configurations for deployment, and the rest of the project for the contract logic.
In summary, moving from scripts to Hardhat Ignition means transitioning from imperative deployment scripting to declarative deployment configuration. This can drastically reduce complexity, make deployments more maintainable and predictable, and overall provides a more robust approach to complex smart contract system deployments. You will write less Javascript and more configuration files, letting Ignition handle the orchestration. Consider this a significant shift in how smart contracts are deployed using Hardhat.