Tenderly Forks: One-Click Development Testnet
Tenderly Forks allow developers to simulate any transaction against real Mainnet data privately, eliminating the overhead of public testnets. Explore the benefits of using Forks as a development testnet and how other Tenderly tools can help speed up testing and debugging.
In this post
Backed by real-time blockchain data and the rest of the all-in-one Tenderly platform, Forks have become an essential step in our users’ development flow. As a powerful, yet forgiving environment, Tenderly Forks are a perfect testing ground for any smart contract scenario.
Forks come even handier now since many of the testnets have been deprecated. Blockchain developers have even reported issues with some faucets running dry, leaving many in the space wondering “now what?”
Many companies in the industry already rely on Forks as their testing environment and you'll see examples later in this post. But there's no better way to succinctly illustrate the process than in the words of Thrilok Kumar, founder and head of product at Instadapp:
“I would say that one of the coolest things that we've integrated and helped us a lot was Tenderly Forks, where we can create a Fork environment from the Mainnet. Then, we can run our whole dashboard in a testing environment, which helped not only the users but also the internal team test any new feature or any product development that we do”.
So, find out why you should use Tenderly Forks for testing, how you can do it, and let your ideas run wild.
Why test with Tenderly Forks
You may be wondering why you should use Forks for testing when you have test networks designed just for that. However, with The Merge implemented successfully, several testnets have been scheduled for deprecation.
Kiln was the first to go and followed by Ropsten and Rinkeby, leaving only Goerli and Sepolia with their own limitations. Sepolia is new, so its state and history are not that comprehensive, while Goerli is a full replica of the Mainnet and takes more time to sync. With Tenderly Forks, on the other hand, you have all the blockchain data you need at all times.
Additionally, when compared to testnets, Tenderly Forks offer more than a few advantages you soon won’t be able to do without. Here’s why you should switch to Tenderly Forks for smart contract testing:
- Greater control: A Fork offers you a high level of customization as you can set up different environment parameters, such as a block number for the next block, gas price, the balance of any account, and even the current time, to name a few. Also, since your Fork is completely private, you’re not affected by external factors that can lead to network congestion and reduce the test execution speed.
- Preconfiguration for different networks: Tenderly supports more than 20 networks (and the list will keep growing). This means you can choose any network and your testing environment will be preconfigured for it. Tenderly Forks perform copy-on-write on a selected network in real time.
This way, we create a replicated production environment with everything you need already deployed, but without any risks from third-party actors.
- Complete privacy: While testing, you probably don’t want to share your work until you’re satisfied with the results. With Forks, you don’t have to since they’re completely private for you and your team and you can control who has access to your project.
- Zero-setup environment: Forks allow you to eliminate the lengthy setup part of your development and testing. With testnets, you still need to go through several tools or setups just so you can deploy your smart contract.
With a ready-to-go Fork environment, you just need to set up the testing parameters relevant to your project. For example, you can specify account balances through API, without having to use faucets or deploy contracts on-chain.
- Unparalleled speed: Running tests on Tenderly Forks is much faster thanks to the speed of smart contract deployments and transaction execution. Also, testnets are public networks, which means there are spikes in network congestion. In return, this can prolong your test execution.
Tenderly Forks make running a test with several transactions faster by orders of magnitude and you get the results almost instantly. Tenderly Forks behave as a local network forking an archive node with a high-performance benchmark.
- Parallel test execution: Want to run multiple tests at once? Why not! Use a separate fork for each test in your test suite and execute them at the same time. On a testnet, you’d have to run tests one by one, while Tenderly Forks let you execute tests in parallel. With this approach, the total time to execute a test suite is limited by the duration of the slowest test!
- Easier team collaboration: With Tenderly Forks, you can easily collaborate across different teams. You can share your Forks with team members, allowing them to re-run tests under the same conditions. This way, you can ensure the accuracy and consistency of your solutions.
How to set up your Fork for testing
Now that you’re familiar with all the benefits of Fork testing, why not experience them firsthand? You can choose between two options:
- Running tests on a Fork from the Dashboard: For a guided approach, head over to Tenderly and create a free account (if you haven’t already). Then, follow a few easy steps to create a new Fork and start running test simulations with customizable parameters.
- Running tests on a Fork from your local environment: If you prefer running your tests programmatically, use our ready-made code to set up a Fork for testing in your local environment. Run the code and Tenderly will set up your Fork with default parameters. Of course, you can also make adjustments as needed.
What other Tenderly features can enrich your tests
Tenderly is an all-in-one Web3 development platform, which means all of our features are interconnected and closely integrated. This also means you have other tools at your disposal while running smart contract tests on a Fork.
Whether you want to test every possible scenario, troubleshoot a failed test, or think of an even better alternative, you can:
- Use Debugger to detect, analyze, and debug issues that have occurred during your test. Debug your simulated transactions or smart contracts in detail by tracing execution steps and decoding both simple and complex expressions.
- Rely on Gas Profiler to break down the gas usage of your simulated transactions in the Dashboard. This will help you understand how your code uses gas per individual function calls. Then, you can optimize gas-heavy lines of code, reducing the gas usage of your smart contracts once they’re deployed to the blockchain.
- Perform one-off simulations with Transaction Simulator if you don’t need an entire Fork for a complex scenario. Also, if your simulated Fork transaction fails, you can use Transaction Simulator to validate individual bug fixes.
- Run a specific simulation on your Fork and turn it into a testing environment. This functionality can be useful when an interesting idea comes to your mind and you decide to run a few tests spontaneously.
How key blockchain players test with Forks
What does testing on Tenderly Forks look like in practice? Let’s explore a few examples from some of the biggest players in the industry:
Tenderly Forks allow the Yield Protocol development team to run different testing scenarios against the Mainnet data. This way, they’re able to ensure the integrity and correctness of bug fixes and protocol changes. Also, since Forks are shareable, Yield Protocol developers are able to easily collaborate with each other and run tests in environments with identical conditions.
As Alberto Cuesta Cañada, Lead Engineer at Yield Protocol, explains: “We use Tenderly Forks as the backbone for our development. I don't know if you could say that something else could create a bigger business impact than that.”
Read the full Yield Protocol case study.
Safe engineers also rely on Tenderly Forks for complex testing scenarios. If their users report any issue, the Safe team uses Transaction Simulator to reproduce the problem. With in-depth data and a complete understanding of how their users interact with their dapps, they can work on possible solutions. However, before implementing bug fixes, they turn to Tenderly Forks to ensure their solutions produce the desired results.
The Safe team also uses Forks to run integration tests, making sure the entire flow works as expected. They use Forks in tandem with other frameworks and tools from their development stack, such as Hardhat. By simply copy-pasting the Fork ID RPC URL, they can use a Fork as the network.
Check out our full case study about Safe.
For the Instadapp team, Tenderly Forks are essential both for internal testing and in production. In production, Forks allow Instadapp’s end users to test yield strategies and whether they’d get the expected end position. This way, Instadapp developers enable their users to execute strategies with confidence.
Internally, the Instadapp team uses Forks to play out protocol integration and ensure their upgrades run as planned. With their own Mainnet replica, they’re also able to test any new feature or product development. Instadapp engineers can see how changes affect their dashboard, whether expected transactions are running, and whether all the values are updated.
Find out more about how Instadapp uses Tenderly.
Use Forks for testing and ensure optimal results
Since smart contracts are immutable, testing plays a crucial role in ensuring their correctness and minimizing possible security risks once they’re deployed. With Tenderly Forks, you get a powerful testing environment where you can try out different dapp or protocol upgrades, play out transaction outcomes, validate bug fixes, and make sure you get the expected outcomes.
On top of that, Forks come backed by the entire Tenderly Web3 development platform, giving you everything you need in a single place. Coupled with Tenderly Web3 Gateway, our new production node offer, you can run tests and deploy smart contracts without switching platforms.
Use Tenderly DevNets to build, test, and debug smart contracts against production data of 30+ EVM networks. Get an unlimited faucet, reusable YAML templates, and built-in debugging tools to deploy on-chain faster.Start building with DevNets!
Subscribe to our newsletter