Skip to main content
Learn how to use Reown AppKit to enable wallet connections and interact with Tenderly Virtual Testnets. With AppKit, you can provide seamless wallet connections, including email and social logins, on-ramp functionality, smart accounts, one-click authentication, and wallet notifications, all designed to deliver an exceptional user experience. With Tenderly’s Virtual TestNets, you can replicate real networks for various stages of your Web3 app development.

Setup

This guide assumes you have already installed and configured Reown AppKit. If you haven’t please follow the installation guide. For this tutorial, we’ll be using Next.js, though you can use any other framework compatible with AppKit.

Create a Virtual TestNet using Tenderly

Navigate to Tenderly Dashboard and login. If you don’t have an account already, then please sign up. Now, navigate to “Virtual TestNets” on the dashboard.
Virtual TestNets dashboard
Click on “Create Virtual TestNet.” Next, you’ll be prompted to select the parent network. For simplicity, select “Sepolia” as the parent network, though you can choose any network you prefer. Now, enter a name for your Virtual TestNet. Under “Chain ID,” select “Custom” and enter a unique chain ID, like “73571,” to avoid conflicts with the existing Sepolia chain. Set “Public Explorer” to “On” and “Smart Contract Visibility” to “Full.”
Create Virtual TestNet configuration
Now, click on “Create” to set up the Virtual TestNet. You will see that your Virtual TestNet has been created, and you can find the RPC and other relevant information for it. Please copy the HTTPS URL under “Public” as this will be your Virtual TestNet’s RPC URL.
Virtual TestNet RPC URL

Build the App

Before we build the app, let’s first configure our .env file. On the root level of your code directory, create a new file named .env. Open that file and create a new variable NEXT_PUBLIC_PROJECT_ID. You will assign the project Id that you copied in the previous step to this environment variable that you just created. You need to do the same for TENDERLY_VIRTUAL_TESTNET_RPC. This is what it will look like:
.env
Please make sure you follow best practices when working with secret keys and other sensitive information. Environment variables that start with NEXT_PUBLIC will be exposed by your app, which can be misused by bad actors.

Configure Tenderly Virtual TestNet with AppKit

In order to set up Tenderly’s Virtual TestNet with AppKit, you need to first configure your Tenderly Virtual TestNet as a custom chain. Inside your /app directory, create a new file named tenderly.config.ts. Now, paste the code snippet shared below inside the code file, i.e., app/tenderly.config.ts.
app/tenderly.config.ts
  1. id — set this to the chain Id that you passed while creating the Virtual TestNet on Tenderly.
  2. url — set this with your Virtual TestNet’s explorer URL. You can find this URL within your Virtual TestNet’s configuration on Tenderly Dashboard.
Tenderly explorer URL
Now, in your config/index.tsx file, import vTestnet from app/tenderly.config.ts. You’ll also need to configure transports within the WagmiAdapter function. Refer to the code snippet below.
config/index.tsx
Now, inside your context/index.tsx file, you also need to import vTestnet and pass it as one of the supported networks within the createAppKit function, as shown below.
context/index.tsx
You can now run the app and test it out. In order to do so, run the command given below.
If you are using alternative package managers, you can try either of these commands — yarn dev, pnpm dev, or bun dev.

Conclusion

And that’s it! You have now learned how to create a simple app using AppKit and configure it with Tenderly Virtual TestNets.

Tenderly Virtual TestNets Example

View the complete code repository here.