Hardhat V2 Quickstart
This quickstart walks you through integrating a Stagenet into your Hardhat V2 workflow. You’ll connect it to a GitHub repository containing your Hardhat project, generate a Contract Workspace for each contract, and activate its Contract Analytics.
Create a Stagenet
Start by creating a new project — each one comes with its own Stagenet. Create one for free here.
Add Stagenet to Codebase
To run Hardhat commands against your Stagenet, you’ll need two things:
- Your Stagenet’s RPC URL
- A funded private key (from the Stagenet’s Wallet Generator)
Get Stagenet RPC URL
First, get your Stagenet’s RPC URL from your contract.dev project's dashboard. It will look like:
https://rpc.contract.dev/3bf1bb611043d73921481c879e5d18faGet Funded Stagenet Wallet
Then, in the sidebar, open Tools → Wallet Generator. Copy the private key and click Fund Wallet. The key will look like:
0x15340a8098a663d3965e0dbdef07606d200a416c9ff1218dc2b452af457ec6fcAdd Stagenet to hardhat.config
Now, add them both to your hardhat.config under a custom stagenet network:
module.exports = {
solidity: "0.8.21",
networks: {
stagenet: {
// Replace with your own Stagenet's RPC
url: "https://rpc.contract.dev/3bf1bb611043d73921481c879e5d18fa",
accounts: [
// Replace with your own funded private key
"0x15340a8098a663d3965e0dbdef07606d200a416c9ff1218dc2b452af457ec6fc",
],
},
},
};You can now execute Hardhat commands against your Stagenet using the funded wallet via the --network flag:
npx hardhat run scripts/my-script.js --network stagenetConnect GitHub Repository
Now connect a GitHub repository that contains your Hardhat project to your Stagenet. Doing this will:
- Import its contracts and generate a dedicated Contract Workspace for each one
- Keep your Stagenet in sync with your repository — pushing new or updated contracts creates new workspaces or versions automatically
To do this, follow these steps::
- Open Repositories via the sidebar and install the contract.dev GitHub App
- Grant it access to the repository that contains your Hardhat project
- Once you’re redirected back, click Add Repository and select your repository
This links your repository to your Stagenet and automatically starts compiling its contracts. After compilation finishes, a Contract Workspace will be created for each one. You can view them by opening the Contracts page from the sidebar.
Activate Workspaces & Analytics
You have imported your contracts into your Stagenet, but you still need to actually deploy them. This will activate their Contract Workspaces and turn on Contract Analytics.
Do this via your usual Hardhat commands:
npx hardhat run scripts/deploy.js --network stagenet
npx hardhat ignition deploy ignition/modules/MyModule.ts --network stagenetWith their contracts deployed, you can now explore your new Contract Workspaces. Inside, you can view real-time activity, inspect storage state, track USD-denominated TVL, and browse each contract’s version and deployment history.
Furthermore, Contract Workspaces stay synced with your GitHub repository:
- Pushing new contracts creates new Workspaces
- Pushing updates to existing contracts automatically creates new Versions
You'll also have enabled Contract Analytics, where you can view contract behavior in ready-made views, or build custom dashboards that track state variables, token balances, function return values, and more.
Next Steps
Congratulations! Your Hardhat V2 project is now wired up to your Stagenet. Simply push new or updated contracts to your linked repository, and they’ll be automatically imported into the Stagenet as you develop. To continue exploring the Stagenet and its suite of built-in tools, follow the links below: