Why Tenderly Simulations Matter for DEFI

Travis Richardson

Technical Writer
Ethereum
GitHub
Notion
Tenderly
In this blog, I’ll explore how I stumbled upon Tenderly, how Tenderly simulations work, and how they can benefit developers and end users.
First, how did I even hear about Tenderly?
To be honest, as I am currently in the job market, I found Tenderly experience listed on several job descriptions as either a requirement or “nice-to-have.” This piqued my interest so I did some research trying to figure out why.
It became pretty simple to understand once I created my account and saw the dashboard.
Figure 1: Tenderly Dashboard
The UI/UX was clean, straightforward, and easy to use and begged to be clicked on and explored!
I quickly realized that the key feature revolved around simulating transactions. This function allowed me to simulate transactions on a real smart contract and even a simulated blockchain, without ever actually sending the transaction!
All I needed to do was create a Tenderly account, give Tenderly a smart contract address, and click Create Transaction!
Pretty easy!
But I also realized that through this portal, I could then do things like debugging, evaluating expressions, setting alerts, and a ton more. Fascinating, and honestly, I started to wonder why all projects weren’t using this as part of their workflow.
I then stumbled upon the SDK and RPC functions around simulations and thought I’d try these out. Since I had recently been playing around with (some of you are likely familiar with this) Speed Run Ethereum by Austin Griffith, I thought I’d see if I could install the Tenderly SDK and simulate some of the transactions from lesson 1, which was a simple defi staking app. So I deployed that bad boy to the Goerli testnet to see what I could do.
Figure 2: Defi Project using Scaffold-eth (before adding simulations)
This defi dapp and smart contract have a few very straightforward functions:
Stake()
Withdraw()
Execute()
TimeLeft()
I was able to test transaction executions without sending them to the blockchain.
Cool!
Figure 3: Defi Project using Scaffold-eth (after adding simulations)
With the SDK, you can do stuff like,
Add a smart contract
Add a wallet
Verify a smart contract
Simulate one transaction
Simulate N transactions (via bundling)
Fork a blockchain and run simulations using the fork.
I learned that Tenderly leverages blockchain history to provide detailed information about state changes, gas usage, emitted events, and all calls made by the simulated transaction. I could even set my transactions up to happen within a certain historical block within a chain’s history.
Very cool!
I was impressed with what Tenderly could do and since I am in a boot camp currently, I thought I’d make a presentation, highlighting for the participants what Tenderly can do!
Figure 4: Video Presentation on Tenderly [link]
Ok… I’m going to digress for a second…
Question: Have you ever been working on something when some influencer you follow distracts you?
I know, this never happens…right? 😂
So the next day (July 5, 2023) after playing around with Tenderly, I woke up and heard about a smart contract where users of that contract force validators to run useless code just to increase gas usage. This was both strange, but interesting, given my awareness of Tenderly’s gas profiling tool.
Figure 5: Crypto Banter Influencer Mentioning Gas Issue
I wanted to verify this, and see what the impacts were!
So I looked up the contract, and found it here then found the smart contract address on etherscan here.
I went ahead and threw it into Tenderly, edited the source code of the smart contract so I could gain entry into the function in question, and voila… When I ran it, I got “Error Message: Out of Gas!
Figure 6: Simulated Transactions on Tenderly
Back to the point…
I’ve enjoyed playing around with Tenderly. I will continue to explore.
Also, I did record a video of one cool feature I found out you can do with Metamask! You may want to check this out for future reference.
Figure 7: Video of Using Metamask and Tenderly to Simulate Transactions[link]
Other cool things I learned include the following:
How to debug a Failed Transactions
How to evaluate transactions using Etherscan.
How to Profile Gas and Improve Your Usage
How to manipulate state
How to give Users Gas-Free Onboarding using a Fork
How to research historical hacks
How does this all impact me as a developer?
Well, as part of my workflow, I’ll be using Tenderly to debug, test, stage, simulate, and automate my development.
Want to see it in action super fast? Just create an account here, and then head over to https://sandbox.tenderly.co/examples/aave-flashloan for a sandbox example.
Last but not least…
Stay tuned, because I dive deeper into Tenderly features and how to use them in my new few posts.
For now, develop well my friends.
Thanks for reading Travis’s Substack! Subscribe for free to receive new posts and support my work.ss
Partner With Travis
View Services

More Projects by Travis