Tenderly

Get started with the all-in-one Tenderly platform and learn how it can help you accelerate development on Cronos. Find out how to use the platform to build, test, improve, and monitor your DApp!

Introduction

The all-in-one Tenderly Web3 development platform combines development tools and observability tightly integrated with blockchain infrastructure building blocks. It enables Web3 engineers to accelerate blockchain development by building, testing, monitoring, and operating smart contracts in one place.

Accelerate Your Web3 Development with Tenderly

Tenderly provides Web3 developers with all the necessary tools to optimize their development workflows and confidently build better dapps. Its tightly integrated tools eliminate fragmentation from the development process, providing a unified developer experience.
Using the Tenderly platform, you can:
  • Build reliable smart contracts faster by ensuring code correctness, previewing execution outcomes, and optimizing gas before deployment.
  • Improve your teams’ development velocity by improving collaboration, sharing test results across teams, and keeping everyone involved to ensure consistency.
  • Create user-focused dapps quickly and confidently by eliminating anxiety and guesswork for your users, providing data-rich notifications, and improving UX.

Tenderly features

Tenderly tools cover each step of smart contract and dapp development. Here are some of the notable tools and features:
  • ​Sandbox is an in-browser prototyping environment that allows Solidity developers to deploy, run, and debug smart contracts almost instantly. It requires no setup and deploys your contract to a Tenderly Fork, which makes it extremely fast. You can choose the Cronos mainnet or testnet as the network for your Sandbox and start prototyping your contracts.
  • ​Tenderly Debugger is a debugging tool that can identify the exact lines of code causing an issue in your smart contract. You can use it to debug your contracts during development or troubleshoot failed transactions in production. It allows you to view transaction calls, evaluate Solidity expressions, review decoded events and state changes, and more.
  • ​Tenderly Debugger Chrome Extension allows you to open Tenderly Debugger from any transaction hash directly from your browser.
  • ​Gas Profiler analyzes smart contract gas usage and breaks it down to individual function calls. It enables you to identify lines of code that consume a lot of gas and then optimize them while still in development.
  • ​Transaction Simulator lets you preview transactions and test smart contracts without deploying them to a network. It also allows you to replay failed transactions so you can analyze their execution and validate potential bug fixes. You can even simulate executed transactions with overridden contract states or transaction parameters.
  • ​Simulation API enables you to integrate Transaction Simulator and use it programmatically. You can use it to expose Transaction Simulator to your end users in your dapp UI. This way, you enable your users to preview transactions directly from your dapp so they can execute them with confidence.
  • ​Tenderly Forks are a private network replica you can use as your personal development or testing environment. A Fork enables you to fork the most recent Cronos mainnet or testnet data. You can then use it to develop, test, and simulate complex transaction scenarios while sharing results with your team. Use a Fork to chain multiple simulations, run complex tests simultaneously, and get complete control over your testing environment.
  • ​Alerting is a part of Tenderly’s observability stack. It allows you to receive custom, real-time notifications to your preferred channel or Webhook endpoint. You can choose a variety of triggers for your alerts so you can stay up to date with specific events on Cronos related to your smart contracts or wallets.
  • ​Web3 Actions are programmable hooks that Tenderly executes automatically when relevant on-chain or off-chain events happen. They allow you to automate your responses and execute custom code whenever something of interest takes place. You can also use Web3 Actions as a serverless backend for your Cronos chain dapps.
  • ​Analytics helps you track trends and metrics on Cronos. You can use it to create custom queries, get in-depth blockchain data, and expose it to your end users. You can also create graphs to represent the data you need visually.
It’s highly recommended to complete smart contract verification on Tenderly to enable all the functionalities of the platform. Tenderly allows you to verify your smart contracts privately, which limits who has access to your contracts while they’re still in development.

Getting started with Tenderly

Some of Tenderly’s features, including Tenderly Explorer and Sandbox, are available without an account. However, to make the most of the Tenderly platform, you should head over to the Dashboard and create an account. You can also use Tenderly tools and features programmatically through Tenderly CLI.
Here’s an overview of the flow that can help you get started with Tenderly:

Prototype and experiment

To quickly experiment and run a smart contract on a Cronos-based Fork, head over to Tenderly Sandbox. Follow these steps to prototype your contracts in your Sandbox environment:
Step 1. Add your Solidity code to the editor on the left. You can also clone someone else’s work if you’d like to play around with code and try your own solutions.
Step 2. Configure the Sandbox environment. Choose the Cronos mainnet or testnet, select the block number, and enter the compiler version and optimizations.
Step 3. Add JavaScript code to the editor on the left. JavaScript allows you to interact with your smart contract, with ethers.js and web3.js readily available.
Step 4. Click the Run button to execute your smart contract. You’ll quickly get the console output and all the simulated transactions in your contract.
Step 5. Open transactions on the Tenderly platform directly from Sandbox. If you come across any issue, jump right into Tenderly Debugger, analyze the problem, and fix it right away.

Add and verify a contract

Tenderly allows you to add verified and unverified contracts to the platform. If you upload an unverified contract, you should verify it on Tenderly so you can use all the functionalities of the platform. Tenderly automatically detects verified contracts on Cronos.

Once in Tenderly, you can add a contract directly from your Project Dashboard by clicking the Add contract button. You can also navigate to the Contracts tab and click the Add Contracts button in the top right corner. Next, follow these steps:
Step 1. Fill in contract details such as the address, network, and name (optional).
Step 2. Toggle the Add more button if you want to add several contracts at the same time.
Step 3. Click the Add contract button to upload the contract.
Step 4. Find the newly added contract in the list of contracts.
Step 5. Click the Verify button on the right if you added an unverified contract.
Step 6. Choose the verification method: JSON upload, ABI upload, or contract source upload.
​
Step 7. Select private or public verification depending on whether you’d like to share your contract with other Tenderly users.
Step 8. Fill in the required details, including compiler parameters, optimization used, optimization count, and others.
Step 9. Finish the verification of your smart contract.
​

Debug and optimize

After adding a Cronos smart contract to Tenderly, you can view all executed transactions in that smart contract. If you come across a failed transaction, you can open it in Tenderly Debugger where you can analyze it in greater detail. Here’s how to do this:
Step 1. Open the transaction of interest to inspect its execution.
Step 2. Click the Contracts tab to see the contracts involved in the transaction.
Step 3. Click the Events tab to explore the events emitted in transaction execution.
Step 4. Click the State Changes to view decoded contract states and state variables.
Step 5. Click the Debugger tab or the Debug Error button to inspect exact lines of code.
Step 6. Click the Gas Profiler button to analyze smart contract gas usage by function calls.
​

Simulate and test

After debugging an issue and optimizing your smart contract, you can use Transaction Simulator to test its execution and validate your fix. This allows you to ensure you’ve applied the right solution before deploying it to Cronos.
To simulate a transaction, head over to the Simulator page in the navigation bar on your left and follow these steps:
Step 1. Click the New Simulation button.
Step 2. Choose the Cronos contract you’d like to use.
Step 3. Update its source code if needed by clicking Edit Contract Source.
Step 4. Choose the function parameter from the dropdown.
Step 5. Fill in transaction parameters in the box on your right (tx index, gas price, value, and others).
Step 6. Click the Simulate Transaction button and check out the output of the simulated transaction.
You can then use the simulated transaction as a starting point for further testing and a basis for a Tenderly Fork environment. Just click the Run on Fork button seen in the screenshot above. This way, you can run a new simulation on top of the previous one and chain multiple scenarios to test them out.
To start from scratch and run new tests, you can create a new Tenderly Fork and use it as your testing environment. To set up a new Fork, follow these steps:
Step 1. Navigate to the Forks tab in the menu on your left.
Step 2. Click the Fork a network button and choose the Cronos mainnet or testnet.
Step 3. Name the Fork (optional) however you’d like.
Step 4. Toggle the Use Latest Block switch if you’d like to use the data up to a specific Cronos block number.
Step 5. Create a new simulation on your Fork by clicking Create Fork Simulation button.
​
Step 6. Choose a previously uploaded contract or upload a custom contract to your Fork.
Step 7. Fill in the remaining fields and run the simulation on the Cronos Fork.
​

Forks and simulation via API

Using Simulation API

If you prefer using Tenderly programmatically, you can integrate the Simulation API. This allows you to run a one-off simulation to visualize the execution of a transaction and utilize relevant data in your dapp. Use the following code to implement it:

Creating Forks via API

Simulation API also allows you to integrate a Fork as a testing environment. To set up a Fork for testing, use the following code:

Track and respond

After testing, optimizing, and deploying your smart contract, you can monitor its on-chain usage and behavior. Tenderly Alerting allows you to stay up to date with any relevant on-chain or off-chain events related to your contract. Here’s how to do this:
Step 1. Go to the Alerts tab on your left and click the Set up Alert button.
Step 2. Choose the trigger that should activate your alert. For example, you can monitor state variable changes and get alert notifications once they happen.
Step 3. Pick the target for your alert such as an address within a specific contract.
Step 4. Specify alert parameters including the relevant contract and the value you’d like to monitor.
Step 5. Set up a destination for your alerts such as email, Slack, Telegram, webhook endpoints, or others.
If you’d like to execute custom code whenever you receive a specific alert or when some other on-chain or off-chain event happens, use Tenderly Web3 Actions to automate your responses.
Here’s how to set up a Web3 Action:
Step 1. Click the Web3 Actions tab in the navigation menu and then Add Action.
Step 2. Choose the event (trigger type) your Action should be listening for, such as block mining.
Step 3. Add the custom code (function) your Action should execute.
Step 4. Specify the trigger for your Action (e.g. the Cronos network and every 100th block mined).
Step 5. Add an Action name and description for future reference.
Step 6. Choose a destination where Tenderly can send you notifications about failed executions.

Resources

For more in-depth information and guidance on how to use Tenderly to accelerate your development on Cronos, explore the resources below.
​
​