Stage Contracts on TestNets
Deploy the latest code and to Virtual TestNets make it available for your team by sharing the RPC link and contract addresses.
Create a TestNet
Create a new Virtual TestNet to stage your contracts, either by:
- Using the Virtual TestNets dashboard
- Using the REST API
Set up environment variables
To create a Virtual TestNet and then deploy and verify contracts, set up the following environment variables:
TENDERLY_ACCOUNT_IDwith your account IDTENDERLY_PROJECTwith your project (slug)TENDERLY_ACCESS_KEYwith the access key you’ve generatedORIGINAL_NETWORK_IDwith the ID of the network you want to base the TestNet onFOUNDRY_REPOwith the path to Foundry repoDEPLOYER_ADDRESSwith the account you’re deploying from- Add other environment variables needed for the deployment scripts
export TENDERLY_ACCOUNT_ID=<USERNAME>
export TENDERLY_PROJECT=<PROJECT>
export TENDERLY_ACCESS_KEY=<ACCESS_KEY>
## TestNet Configuration
export TENDERLY_TESTNET_NAME=staging
export PURPOSE=development
export ORIGINAL_NETWORK_ID=1
export BLOCK_NUMBER=latest
## Custom Chain ID (Prefixed with 7357 - test)
export CHAIN_ID=7357$ORIGINAL_NETWORK_ID
## Public explorer verification visibility
## abi | full | none
export VERIFICATION_VISIBILITY=abi
# Foundry Repo (Absolute path only!)
export FOUNDRY_REPO=<ABSOLUTE PATH TO FOUNDRY PROJECT>
## Deployer address
export DEPLOYER_ADDRESS=...
## Custom stuff needed for deployment scripts
## Add your custom stuff here
export ADMIN_ADDRESS=...Write your deployment commands
Edit deploy-command.sh and add commands to deploy your contracts. Note you’ll have to add verification to your Foundry or Hardhat project.
For example:
#!/bin/bash
cd $FOUNDRY_REPO
## TODO: Your deployment command here:
MAX_SEGMENT_COUNT=3
FOUNDRY_PROFILE=optimized \
forge script script/DeployCore.s.sol \
--broadcast \
--rpc-url $TENDERLY_VIRTUAL_TESTNET_RPC \
--sig "run(address)" \
--verify \
--verifier-url $VERIFICATION_URL \
$ADMIN_ADDRESSStage contracts
Run the following commands that will:
- create a new Virtual TestNet
- fund the
$DEPLOYER_ADDRESSwith test ETH using the Infinite faucet - configure Foundry’s
foundry.tomlfor verification on your custom chain - deploy your contracts
- and finally clean up
foundry.toml
# create a testnet - or paste the Unlocked TestNet RPC URL
source src/contracts-staging/.env
cd src/contracts-staging
## Create a fresh testnet
export VIRTUAL_NETWORK_RPC_URL=$(./create-testnet.sh)
echo "Created a Virtual TestNet at ${VIRTUAL_NETWORK_RPC_URL}"
### run the deployment
./deploy-to-testnet.shThe RPC Link is shown in the output, and your contracts are deployed and verified on the Virtual TestNet.
Share the addresses
Collect the ABIs and addresses of deployed contracts and distribute them to your team, together with TestNet RPC.