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

All Products

Virtual TestNets
Develop
Deploy Contracts

Deploy Contracts on TestNets

Learn how to deploy smart contracts on your TestNet using Hardhat and Foundry.

Contracts deployed on a TestNet are called virtual contracts. You can find them in the Contracts section under the Virtual Contracts tab.

It’s recommended to verify your contracts as you deploy them, so you can use the Debugger, Gas Profiler, Simulator, and other tools.

Prerequisites

You have created a VirtualTestNet.

Deploy contracts using Foundry

You can deploy contracts to Virtual TestNets using Foundry’s forge create:

Run forge create

Pass the RPC URL to TENDERLY_VIRTUAL_TESTNET_RPC as the --rpc-url parameter. Then, run the forge create command.

PRIVATE_KEY=... # private key - if needed
TENDERLY_VIRTUAL_TESTNET_RPC=... # paste the RPC URL here
 
forge create Counter \
--rpc-url $TENDERLY_VIRTUAL_TESTNET_RPC \
--private-key $PRIVATE_KEY

Check the dashboard

In the Dashboard, go to Contracts and open Virtual Contracts tab, where you’ll find your contract.

Verify contracts

To learn more about verifying contracts with Foundry, explore the following guide:

Deploy contracts using Hardhat

At the moment, the @tenderly/hardhat-tenderly plugin for Hardhat is compatible with Hardhat up to version 2.22.0. Learn more about compatibility here.

To deploy a contract to your TestNet using Hardhat, you need to use the Tenderly-Hardhat plugin. Install the Tenderly-Hardhat plugin here and follow the steps below:

Add the RPC

Open the hardhat.config.ts and add virtualMainnet as a new network. You also need to provide the RPC URL of your TestNet (networks.virtualMainnet.url) and the chain ID you’ve set during the creation of the TestNet.

Naming recommendation: prefix the name with virtual for easier distinction from other networks.

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
 
const config: HardhatUserConfig = {
  solidity: "0.8.19",
  networks:{
    virtualMainnet: {
      url: "RPC URL here",
      chainId: 73571 // the Chain ID you selected during creation
    }
  }
};
 
export default config;

Deploy

Run the deploy script with --network virtualMainnet.

npx hardhat run scripts/deploy.ts --network virtualMainnet

Check the dashboard

In the Dashboard, go to Contracts and open Virtual Contracts tab, where you’ll find your contract.

Verify contracts

To verify contracts on Virtual TestNets, explore the following guide:

Next Steps

  • Stage contracts: Deploy the latest code and make it available for your team by sharing the RPC link and contract addresses.
  • Fork a TestNet:
  • Stage dapps: Learn how to connect the TestNet to you dapp’s UI