Deploy with Hardhat V2
Use Hardhat with a Stagenet
Configure Hardhat to deploy contracts to your Stagenet, run scripts against its RPC URL, and activate Workspaces for deployed contracts.
Deploy contracts from an existing Hardhat V2 project to your Stagenet by adding it as a custom network in hardhat.config and using your existing deploy scripts with --network 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 (e.g.
scripts/deploy.js) - A Stagenet — create one in the dashboard if you don’t have one yet
- 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 network.
For real projects, load the RPC URL and key from .env rather than hard-coding them.
Deploy with hardhat run
Run your existing deploy script with --network stagenet:
npx hardhat run scripts/deploy.js --network stagenetHardhat sends the deployment transactions through your Stagenet’s RPC. The contracts persist on the Stagenet and can be inspected from the dashboard.
Auto-generated Workspaces
To get a dedicated Workspace for each deployed contract — with activity, balances, TVL, storage, and tracked metrics — push the contracts to your Stagenet before deploying.
Install the CLI and initialise it with your Stagenet’s RPC URL:
npm install contract.dev
npx contract.dev init --rpc-url=<YOUR_STAGENET_RPC_URL>Then compile and push:
npx hardhat compile
npx contract.dev push-contractsEach pushed contract becomes a pending Workspace. When hardhat run deploys a contract whose bytecode matches a pushed artifact, the Stagenet activates its Workspace automatically.
Re-run npx contract.dev push-contracts after any contract changes to keep your Stagenet in sync. To have new and updated contracts pushed automatically on every commit, set up GitHub CI/CD.
See the push-contracts reference for details on source/artifact directory overrides and Hardhat configs that compute paths dynamically.
Next steps
- Workspaces — inspect each deployed contract in its own dashboard.
- Tracked Data — record and graph contract balances, storage variables, and function outputs over time.