Virtual TestNets are live! ⚡️ Test and stage dapps on real-time production data.
Get started →

All Products

DevNets with Hardhat

DevNets with Hardhat

Hardhat is an Ethereum development environment that simplifies smart contract development, testing, and deployment.

Manual RPC URL creation via Spawn DevNet

To set up DevNet with Hardhat, follow these steps:

  1. Install Hardhat if you haven’t already:
yarn add --dev hardhat
  1. Create a hardhat.config.js file in your project directory and configure it to use the DevNet JSON-RPC URL that you have copied from DevNets.
module.exports = {
  networks: {
    devnet: {
      chainId: 1,

Replace YOUR_DEVNET_JSON_RPC_URL with the DevNet RPC URL, you obtained from Tenderly by Spawning a DevNet via UI.

Automatic creation of RPC URL

One alternative is to utilize the spawn-rpc CLI command, which enables the automated process of spinning up a DevNet and injecting it directly into your HardHat config file.

Each time the spawn-rpc the command is called, a new RPC URL will be generated from a fresh state of the specified network based on template.

brew tap tenderly/tenderly && brew install tenderly
tenderly login
tenderly devnet spawn-rpc --project <YOUR_PROJECT_SLUG> --template <YOUR_TEMPALATE_SLUG>
# prompts active devnet RPC URL

See an example of how you to integrate CLI into your project.