Deploy with Hardhat V2
This guide shows you how to deploy contracts from a Hardhat V2 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 V2 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 to the networks block in your hardhat.config.{js,ts}:
module.exports = {
solidity: "0.8.21",
networks: {
stagenet: {
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 contracts
Run your deployment scripts 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 stagenetHardhat sends the deployment transactions through your Stagenet’s RPC from your funded wallet.
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.