Skill 4.2.3

Deploy contracts with Hardhat Ignition and scripts

Key Concepts

Hardhat Ignition is Hardhat's declarative deployment system. A module describes what to deploy, for example const token = m.contract("MyToken", [initialSupply]); and calls to make after deployment with m.call(...). npx hardhat ignition deploy ignition/modules/MyToken.js --network sepolia executes the module, sends transactions in dependency order and waits for confirmations.

Ignition records each deployment's state in ignition/deployments/chain-<id>. If a deployment is interrupted, running the same command resumes where it stopped instead of redeploying, and running it again after success does nothing. The deployed addresses are written to deployed_addresses.json. Parameters can be supplied per network with a parameters file.

Deployments can also be scripted imperatively, for example with ethers.js (ethers.deployContract("MyToken")) or web3.js (contract.deploy({ data, arguments }).send({ from })). Scripts give full control but must handle failures and record addresses themselves. Older projects used Truffle migrations for the same purpose.