Setting up DevNets for local development offers several benefits, including faster development and testing, customization of the network state, privacy and security, independence from public testnets, and integration with development tools.
Before setting up a DevNet locally, make sure to:
- Create a Tenderly account.
- Set up a DevNet Template on Tenderly Dashboard.
- Install the Tenderly CLI and login with your Tenderly credentials.
To set up DevNet with Hardhat:
- Install Hardhat.
- Configure
hardhat.config.js
with your DevNet JSON-RPC URL and network name must be eithertenderly
ordevnet
.
Alternatively, use the spawn-rpc
CLI command to automate the process.
Refer to the CI-project example for more details.
To set up DevNet with Foundry:
- Make sure you have Rust and Foundry.
- Initialize a dummy Foundry project.
forge init
- Deploy smart contracts using the forge create command.
forge create --rpc-url=$(tenderly devnet spawnRPC --template <YOUR_TEMPALATE_SLUG> --project <YOUR_PROJECT_SLUG>) ./src/Counter.sol:Counter --unlocked --from 0x0000000000000000000000000000000000000000
To set up DevNet with Truffle:
- Install Truffle.
npm install -g truffle
- Configure truffle-config.js with your DevNet JSON-RPC URL and Ethereum address.
module.exports = {
networks: {
devnet: {
host: "YOUR_DEVNET_JSON_RPC_URL",
network_id: "*",
gas: 4700000,
gasPrice: 20000000000,
from: "YOUR_ETHEREUM_ADDRESS"
}
}
};
- Run
truffle migrate
to deploy your contracts.
truffle migrate --network devnet
To integrate DevNet with your CI pipeline, use the spawn-rpc
CLI command to spawn a DevNet instance and get the JSON-RPC URL.
tenderly devnet spawnRPC --template <YOUR_TEMPALATE_SLUG> --project <YOUR_PROJECT_SLUG>
Please refer to the CI-project example for more details.
For more information on DevNet, check out the following resources: