Test transaction outcomes from Tenderly Web3 Gateway, the first node as a service that offers simulations from the same RPC. Try it for free in your dashboard.

Infra 3.0

Simulate Transactions in Web3 Gateway: One Node to Rule Them All

Tenderly's production node Web3 Gateway now supports transaction simulations, allowing developers to dry-run transactions and send them on-chain through a single RPC URL.

Andrej Bencic
Andrej Bencic
Dec 7, 2022 · 5 min read

In this post

Simulate Transactions in Web3 Gateway: One Node to Rule Them All

Tenderly is bringing transaction simulations to Web3 Gateway. As the first Web3 development platform to offer simulations through RPC, Tenderly provides an integrated environment for simulating and sending transactions in one place. And with 50 million simulations already processed by Tenderly per month, we’re now introducing the same capabilities to the world of JSON-RPC.

Running a simulation and sending transactions with Web3 Gateway is as simple as adding a single RPC URL to your project. Rather than wasting time on unnecessary configuration steps, you can now focus on building smarter and more efficient dapps.

Driving informed decisions with transaction simulations

Tenderly Web3 Gateway, a production node as a service solution, enables Web3 developers to interact with the blockchain easily and scale their infrastructure faster. To query on-chain data or send transactions, all you need to do is add a single RPC URL to your dapp.

With the latest addition of simulations to Web3 Gateway, you can also dry-run transactions before sending them. This is made possible through a new custom-built RPC endpoint.

The key benefit of simulating transactions is to understand how the transaction would behave on-chain without submitting it and spending money on gas. Simulations can also improve your visibility into transaction failures, help you prevent undesired events, and drive informed decisions before sending transactions.

Similarly, you can integrate simulations into your dapp to provide users with a more transparent and predictable experience. Simulations can give your users a detailed preview of the expected outcome of their transactions and estimated gas costs. Giving your users this option can make them feel more confident when using your dapp, while you’ll have fewer support tickets to worry about.

Initiating a simulation in Web3 Gateway requires basic knowledge and minimal setup. This makes Web3 Gateway an ideal node solution for beginner developers who are exploring different transaction optimization best practices.

Tightly integrated environment for simulating and sending transactions

We’ve made it extremely easy to dry-run transactions within Web3 Gateway. All you have to do is add the Web3 Gateway RPC URL to your source code and call our custom-built RPC endpoint tenderly_simulateTransaction.

Custom-built RPC endpoint enabling seamless simulations

Simulations in Web3 Gateway allow you to simulate smart contract behavior and speed up development without configuration pain. You no longer have to worry about integrating separate APIs for simulations and deployment.

With a single RPC URL to perform all these operations in one place, you also don’t have to waste time managing various access keys and stressing over something breaking in the process.

Blazing fast response time

Dapps that process large volumes of transactions require fast response times and minimal latency to deliver a smooth user experience.

When simulating transactions through Web3 Gateway, the results will be returned to you almost instantly. This is thanks to the multi-regional architecture of Web3 Gateway that automatically routes your simulation requests to a location closest to you.

Simulate against real Mainnet data

Transaction simulations are always executed against the most up-to-date Mainnet data. This eliminates the guesswork and manual effort that goes into ensuring the success of transactions before they hit the blockchain.

If the simulation fails, you can quickly make adjustments to ensure the transaction is successful when sent on-chain. This functionality also allows you to save on gas fees since you’ll only be sending transactions that are sure to succeed.

You can also expose this functionality to your users through your dapp, allowing them to dry-run transactions and make informed decisions about whether to proceed. For example, if a user attempts to send an invalid transaction, simulations give your dapp the ability to immediately inform the user of any errors.

100% accurate results

Since transactions are simulated against the latest state of the blockchain, you get accurate insights into what would happen if you send them on-chain. The simulation results you get back from Tenderly can help you correct errors and understand the outcome of transactions being added to the blockchain.

Simulation results include the following data:

General info about the transaction

  • Status of the transaction (failed or successful)
  • Gas consumed to process the transaction
  • Decoded returned output of the transaction

Info about internal transactions

  • Caller and called contracts
  • Array of the function call trace, including decoded arguments, decoded return arguments, the value sent, and other related data

Logs

  • Details about emitted events
  • Decoded event names and parameters

Reference the docs for a detailed description of simulation results.

Quick starter guide for simulating transactions in Tenderly Web3 Gateway

To enable simulations through We3 Gateway, Tenderly exposes a special RPC method tenderly_simulateTransaction. You can call this method and initiate a simulation in two ways:

  • Manually from the Dashboard
  • Programmatically from your code through an RPC URL

This starter guide will show you how to set up a quick simulation through your browser. However, if you want to jump into the code straight away, check out our documentation for a detailed guide on how to call the tenderly_sumulateTransaction method from your code.

Step 1: Log in and access Web3 Gateway

First, log into your Tenderly account and access Web3 Gateway.

Web3 Gateway dashboard

Step 2: Configure the simulation request and execute it

Next, scroll down to the Request Builder and select the network – Mainnet or any of the available testnets. To run a simulation on the selected network, choose the first method from the dropdown tenderly_sumulateTransaction and fill out the available fields.

RPC Request Builder in Web3 Gateway

Click the Send Request button at the bottom of the page to execute the simulation.

To view the results of your simulation, take a look at the Response Preview panel. If you’re happy with how you’ve configured the simulation request, you can go to the Request Preview panel to copy the code snippet and paste it into your dapp.

Request Preview in Web3 Gateway

Reliability and speed built into a production node

As a managed node as a service solution, Tenderly Web3 Gateway helps you eliminate the costs and headaches of running and managing your own node infrastructure. Tenderly’s node also delivers up to 8x faster read-heavy workloads, 100% data consistency, and reliable infrastructure that scales easily.

To help you get on board, we’ve launched an early adopters program that offers more compute power at special pricing. Check out our post on Getting Started with Tenderly Web3 Gateway to learn how to integrate Web3 Gateway into your dapp in three easy steps.

Ready to get started right away? Launch Web3 Gateway here.