ℹ️Dynamic Logging

Dynamic logging provide an easy way to inspect state of transaction during execution with Simulation. It allow developer to add logs like

console.log("%d", localVar);

into any on-chain contract and extract the information with simulation.

The following video shows the full workflow how you can use it.

To do dynamical logging, there are multiple ways, either by Web UI or IDE & Command Line. If the contract is developed by yourself, also consider use hardhat plugin to Upload Compilation.

Web UI

Open a transaction's contract tab, e.g. here. Click the "Start Override" Button.

Then you will enter editing mode. At the top of the file, insert

import "sentio/console.sol"

to the import section of the file. And then you can do any console log just as you can do with hardhat or foundry. As the follow picture shows, once the editing is done, click "Submit & Simulate".

Sucess uploading will generate an compilation with ID.

Continue with "Open Simulator", all parameters especially the source override will be configured correctly.

Once simulation is done, the console log will be put in the top section.

IDE & Command Line

You can also do that in your local VS Code if you need more advanced editing, first download the contract as zip.

After extracting the zip file, you will get file structure like this. It is recommended to use VS Code as the development environment, which has better linting support.

  • /src contains source code for the contract.

  • /metadata.json contains necessary information for compiling and uploading.

  • /compile.sh fetch solidity compilers and compile on your local machine.

  • /upload.sh upload modified source code to Sentio.

In the source folder, sentio/console.sol will be included besides the original sources of the contract. It contains utilities for printing debug information in simulation and transaction replaying, just like console.log in javascript. Console outputs will be collected and displayed on Sentio debugger.

  1. import sentio/console.sol

  1. Add logs wherever you want

  1. Try compiling on your local machine. Note that for old versions of solidity compilers, warnings may appear in the console. It won't affect actual compiling process.

  1. Upload your compilation to Sentio

If you haven't login with Sentio CLI before, you may need to login first following the instructions in the console.

Now you can go back to the original transaction page, open simulator and choose your compilation in Source Override section and start simulation.

Last updated