hardhat-deploy
A Hardhat plugin for replicable deployments and easy testing.
hardhat-deploy v2 runs rocketh inside Hardhat. You write deploy scripts in your project's deploy folder, hardhat deploy --network <name> runs them against that network and records what they deployed, and your tests run the same scripts as a fixture, so they test the contracts as they are deployed. Accounts are named (deployer, admin) rather than indexed, proxies and diamonds are declared rather than hand-upgraded, and a proxy owned by a Safe is upgraded through the Safe, rehearsed on a fork first.
This is the documentation of v2, for Hardhat 3. It is a section of the rocketh documentation because hardhat-deploy is rocketh plus Hardhat: everything about deploy scripts, accounts, proxies, forks and Safes is shared with plain rocketh, and lives in the shared pages with the hardhat deploy command shown; the pages of this section cover what exists only because of Hardhat. The documentation of v1 is on its v1 branch.
Coming from hardhat-deploy v1?
Start with Coming from hardhat-deploy v1: what v1 has that v2 does not, what changed, and whether your project can move, then the step-by-step migration.
The path
- Get started with hardhat-deploy:
hardhat-deploy init, or setting up a project by hand. - Deploy scripts, tags and dependencies and Deploy contracts: what a script is and what
deploydoes. - Named accounts and signers and Networks and accounts from the environment: deploying to a real network.
- Upgradeable contracts with proxies, and as you need them Diamonds, Routers and Deterministic addresses.
- Tests with Hardhat fixtures: your deploy scripts as a test fixture, in TypeScript and in Solidity tests.
- Rehearse on a fork:
HARDHAT_FORK, and what a rehearsal inherits from the network it forks. - A Safe-owned project, end to end: a proxy owned by a Safe, from deployment to an upgrade executed in the Safe app.
- Export, verify and document: your deployments for a frontend and a block explorer.
Only in hardhat-deploy
- The
hardhat deploytask: its options, and how they map to therockethcommand. - Networks and accounts from the environment:
addNetworksFromEnv,addNetworksFromKnownList,addForkConfiguration,HARDHAT_FORK. - Typed artifacts: the
artifactsandabismodules generated from each compilation. - Scripts and the Hardhat connection:
loadEnvironmentFromHardhat,env.hardhatConnectionandenv.getHardhatConnection()(hardhat-deploy/extensions). - Development workflow: a local node, and redeploy on change (Hot Contract Replacement).
For a complete project to start from, see template-ethereum-contracts. The plugin's source and issues are in the rocketh repository.