All Products

DevNets
Automated DevNet Spawning: Bash & JavaScript

Automated DevNet Spawning: Bash & JavaScript

Through the steps below, you can seamlessly spawn DevNets in your development workflow using either Bash or JavaScript.

Prerequisites

Before proceeding, ensure your system meets these requirements:

  1. bash and/or node installed on your system.
  2. Tenderly CLI installed and authenticated.

Clone repository with scripts

Clone the GitHub repository and navigate to the spawn-devnet-auto directory:

bash
git clone git@github.com:Tenderly/devnet-examples.git
cd devnet-examples/spawn-devnet-auto

You will find two directories with code for spawning DevNets:

  • a bash version: spawn-devnet.sh
  • a JS version: spawn-devnet.js

Spawning via Bash

Navigate to bash folder

bash
cd ./bash

Set up environment variables

Create an .env file in your project directory and include the necessary environment variables:

.env
TENDERLY_DEVNET_TEMPLATE=your_template
TENDERLY_PROJECT_SLUG=your_project_slug

Run the spawn-devnet.sh script

To run the script, use the following command in your terminal:

bash
./spawn-devnet.sh

The script spawns a DevNet, extracts the RPC URL, and sets it as an environment variable in your .zshrc file.

Spawning via JavaScript

Navigate to the js directory

example
cd ./js

Set up an .env file

Create a .env in your project root, and include the following values:

example
TENDERLY_ACCESS_KEY=your_access_key
TENDERLY_PROJECT_SLUG=your_project_slug
TENDERLY_DEVNET_TEMPLATE=your_devnet_tempalte
TENDERLY_ACCOUNT_ID=your_account_id

Run the spawn-devnet script

To run the script, use the following command in your terminal:

bash
yarn spawn-devnet

The script spawns a DevNet, extracts the RPC URL, and updates it in your .env file.