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

  1. Get started with hardhat-deploy: hardhat-deploy init, or setting up a project by hand.
  2. Deploy scripts, tags and dependencies and Deploy contracts: what a script is and what deploy does.
  3. Named accounts and signers and Networks and accounts from the environment: deploying to a real network.
  4. Upgradeable contracts with proxies, and as you need them Diamonds, Routers and Deterministic addresses.
  5. Tests with Hardhat fixtures: your deploy scripts as a test fixture, in TypeScript and in Solidity tests.
  6. Rehearse on a fork: HARDHAT_FORK, and what a rehearsal inherits from the network it forks.
  7. A Safe-owned project, end to end: a proxy owned by a Safe, from deployment to an upgrade executed in the Safe app.
  8. Export, verify and document: your deployments for a frontend and a block explorer.

Only in hardhat-deploy

For a complete project to start from, see template-ethereum-contracts. The plugin's source and issues are in the rocketh repository.

Search
Search the documentation