Deploy with Hardhat V3
This guide shows you how to deploy contracts from a Hardhat V3 project onto your Stagenet.
You do not need to change your contracts or your scripts. Just add a network entry pointing at your Stagenet’s RPC URL.
Prerequisites
- A Hardhat V3 project with a deployment script or Ignition module
- A funded deployer wallet:
- generate one with the Wallet Generator
- or fund an existing address using the Faucet
Add your Stagenet as a network
Copy your Stagenet’s RPC URL from its dashboard and add a stagenet entry under networks in your hardhat.config.{js,ts}:
export default defineConfig({
networks: {
stagenet: {
type: "http",
chainType: "l1",
url: "<YOUR_STAGENET_RPC_URL>",
accounts: [
"<YOUR_FUNDED_PRIVATE_KEY>",
],
},
},
});Stagenets expose a standard Ethereum JSON-RPC interface, so Hardhat talks to them the same way it talks to any other EVM blockchain.
Deploy with hardhat run
Run your deployments against your Stagenet with --network stagenet:
npx hardhat run scripts/deploy.ts --network stagenetOr use ignition:
npx hardhat ignition deploy ignition/modules/MyModule.ts --network stagenetTo enable auto-generated Workspaces from contract imports while using Ignition, pass --build-profile default.
Ignition uses an optimised build profile by default, which strips the metadata needed to match the bytecode of imported contracts:
npx hardhat ignition deploy ignition/modules/MyModule.ts --network stagenet --build-profile defaultHardhat sends the deployment transactions through your Stagenet’s RPC.
Next steps
To get automatic Workspaces — dashboards that show contract transaction, balances, TVL, storage, and more — for each of your deployed contracts, import them onto your Stagenet.
You can do this via:
- Via the CLI by running
npx contract.dev import-contractsin your Hardhat project. - Importing them from GitHub with the Stagenet’s CI/CD
When you import them, their deployments will be detected as instances of the imported contracts and they will have Workspaces created for them automatically.