Skip to content

chore(deploy): migrate to Hardhat v3 + hardhat-deploy v2 (rocketh) - #14

Merged
FabienCoutant merged 1 commit into
devfrom
chore/hardhat-v3-migration
Jun 18, 2026
Merged

FabienCoutant merged 1 commit into
devfrom
chore/hardhat-v3-migration

Conversation

@FabienCoutant

Copy link
Copy Markdown
Contributor

Overview

Migrates the deployment toolchain from Hardhat v2 + hardhat-deploy v0.14 (ethers v5) to Hardhat v3 + hardhat-deploy v2 built on rocketh (viem), mirroring the parallel-parallelizer setup. Smart contracts and Foundry tests are unchanged.

Motivation: the old hardhat-deploy is unmaintained for Hardhat v3, and its ethers v5 path is what caused the post-deploy to:"" crash on the recent sPRL2V2 mainnet deploy.

Stack

hardhat@3, hardhat-deploy@2, rocketh + @rocketh/* (0.19.x), viem, @nomicfoundation/hardhat-viem. ESM ("type": "module").

Changes

Foundation

  • package.json: "type": "module"; deps swapped; scripts (verify → rocketh-verify etherscan, add size); dropped hardhat-foundry / hardhat-contract-sizer.
  • tsconfig.json: ESM (esnext / bundler), @rocketh + @generated/* path aliases.
  • hardhat.config.ts: v3 plugins array, networks type: "http", PRIVATE_KEY accounts, solc 0.8.25/cancun. Hardhat sources pinned to contracts/ and its test dir redirected so Foundry tests under test/ are not compiled by Hardhat. remappings.txt gains contracts/=contracts/.
  • rocketh.ts (new): typed config + deploy/read-execute/proxy/viem extensions, setupDeployScripts, re-exports generated artifacts.
  • commitlint.config.js → .cjs (CommonJS under ESM).

Deploy scripts (sPRL1/sPRL2/sPRL2V2, MainFeeDistributor, SideChainFeeCollector, RewardMerkleDistributor)

  • Rewritten to the deployScript(env) API: env.deploy({ account, artifact, args }), network name via env.name, uint args as BigInt.
  • deploy/utils switched from ethers v5 to viem (isAddress / zeroAddress).
  • Removed the obsolete sPRL2V2.recover.ts and utils/getVerifyConfig.ts.

Verification now uses @rocketh/verifier (ETHERSCAN_API_KEY env, Etherscan V2); .env.example updated.

Validation (CI green locally)

  • tsc --noEmit clean.
  • forge fmt --check, solhint, prettier:check pass.
  • forge build --sizes + hardhat compile generate generated/ artifacts.
  • forge test: 188 passed, 0 failed.
  • End-to-end deploy dry-run of sPRL1 on an in-memory network succeeds (arg encoding + bytecode broadcast + deploy).

Notes

  • Hardhat 3 is still in beta.
  • The parallel-parallelizer committed rocketh.ts is stale vs its installed rocketh 0.19 (uses the removed setup API); this PR uses the correct 0.19 setupDeployScripts API.
  • Requires ETHERSCAN_API_KEY (unified V2 key) in .env for verification.
  • Pre-existing deploy/config WIP changes are intentionally left out of this PR.

Replaces the Hardhat v2 + hardhat-deploy v0.14 (ethers v5) deploy
toolchain with Hardhat v3 + hardhat-deploy v2 built on rocketh (viem),
matching the parallel-parallelizer setup.

Foundation:
- package.json: "type": "module"; swap hardhat-deploy@0.14 ->
  hardhat-deploy@^2, hardhat@^3, rocketh + @rocketh/* (0.19.x), viem,
  @nomicfoundation/hardhat-viem; drop hardhat-foundry/contract-sizer;
  scripts: verify -> "rocketh-verify etherscan", add "size".
- tsconfig.json: ESM (esnext/bundler), @rocketh and @generated aliases.
- hardhat.config.ts: v3 plugins array, networks with type:"http",
  PRIVATE_KEY accounts, solc 0.8.25/cancun. Hardhat sources pinned to
  contracts/ with tests redirected so Foundry tests under test/ are not
  compiled by Hardhat. remappings.txt gains contracts/=contracts/.
- rocketh.ts: typed config + deploy/read-execute/proxy/viem extensions,
  setupDeployScripts, re-exports generated artifacts.
- commitlint.config.js -> .cjs (CommonJS under ESM).

Deploy scripts (sPRL1/sPRL2/sPRL2V2, MainFeeDistributor,
SideChainFeeCollector, RewardMerkleDistributor):
- rewritten to the deployScript(env) API: env.deploy({account,
  artifact, args}); network name via env.name; uint args as BigInt.
- deploy/utils switched from ethers v5 to viem (isAddress/zeroAddress);
  removed the obsolete sPRL2V2 recover script and utils/getVerifyConfig.

Verification now uses @rocketh/verifier (ETHERSCAN_API_KEY env);
.env.example updated.

Validated: tsc --noEmit clean, forge build + hardhat compile generate
generated/ artifacts, and an end-to-end deploy dry-run of sPRL1 on an
in-memory network succeeds.
@FabienCoutant
FabienCoutant merged commit 45cb22b into dev Jun 18, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant