Debugging Ethereum transactions in the Remix IDE

Web3 is booming right now. Things you can do just using Ethereum smart contracts is on a completely different level; developers are already creating smart contracts on the Ethereum blockchain for multiple use cases, include NFTs, cryptocurrency, collecting payments, and managing data in a decentralized manner.

Like every other programming language, Solidity (the language used to make smart contracts) also needs debugging in order for the application to work properly. Using the Remix IDE, you can find the proper debugging tools so that you can keep track of how the state of the smart contract changes as the code gets executed, see variable values at any given point, and much more. Today, we are going to discuss how to properly debug Solidity contracts.


  • Working knowledge of Solidity – I won’t recommend this tutorial to complete beginners
  • Access to Remix. We won’t be using code editors like Visual Studio Code in this tutorial

Creating a smart contract

When you open Remix, navigate to the contracts folder and create a new file named Debugging.sol. Add the following contents to it:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
contract Debugging {
    uint256 counter;
    constructor(uint256 _counter) {
        counter = _counter;
    function _setCounter(uint256 _counter) internal {
        counter = _counter;
    function increment(uint256 value) public {
        uint256 newValue = counter + value;
    function decrement(uint256 value) public {
        uint256 newValue = counter - value;
    function getCounter() public view returns(uint256) {
        return counter;

Above is the code for a basic smart contract written in Solidity. It keeps a track of a counter. I’ve made more functions than strictly required in order to demonstrate the flow of a contract while debugging.

Note that we are using v0.8.4 in this tutorial, but feel free to change the compiler settings to match the version, or use a completely different version if you want.

Compiling and deploying the smart contract

Now go to the compiler tab of the editor, which is the second icon on the sidebar, and you should see the compiler settings.

Screenshot of Solidity compiler

Go ahead and click on Compile Debugging.sol. Now go to the deployment tab, which is the third icon on the sidebar. You will see the deployment tab as shown below:

Solidity deployment tab

Make sure the environment is set to one of the JavaScript VMs, we won’t cover deployment to actual networks in this tutorial, but it should work pretty much the same. Add a counter in the constructor field near the Deploy button. I’ve set it to zero, which will set the initial value of the counter.

Once you click on Deploy, you should see your smart contracts under the Deployed Contracts section:

deployed contracts section

These are the functions that we made public in our smart contract and are accessible through these buttons. Using the text boxes near the buttons, you can pass parameters with the function.

Debugging the smart contract

Now let’s move on to the fun part, debugging the smart contract. To debug, we first need to create a transaction, which means we need to interact with the part of the smart contract we want to debug.

In this case, I’ll use the increment function as an example and pass 1 as the parameter to increase the counter by one. Press the increment function to run the smart contract. When the transaction completes or fails, you will see something like this in the Remix terminal:

Screenshot of pending transaction debugging

Now, press the Debug button and we will be presented with the debugger:

Solidity debugger panel

There are a lot of buttons and information in this panel. Let’s see what the buttons mean here:

Slider with numbered arrow buttons

Here are the description of the labels:

  1. Step over back goes to the previous step. Function calls will be ignored and the debugger won’t enter the function
  2. Step back goes to the previous step. Functions will not be ignored and the debugger will enter the functions
  3. Step into goes to the next step and the debugger will enter function if there is a function call
  4. Step over forward goes to the next step, but function calls are ignored and the debugger will not enter the function
  5. Jump to previous breakpoint takes the debugger to the last visited breakpoint. Breakpoints can be set by clicking the line number of code
  6. Jump out takes the debugger to the end of the function
  7. Jump to next breakpoint takes the debugger to the next set breakpoint in the editor

You can also use the slider and simulate the transaction as the slider moves.

Now let’s debug and see how the flow of the increment function is moving. When you first launch the debugger on this transaction, you should see this part of code highlighted:

Highlighted Solidity code

This means that the newValue variable is being created. When we press Step into, you should see that the code is highlighted near counter and value, simulating how the addition is working.

Eventually, after a few steps, you will see the Solidity Locals panel change like this:

Solidity locals panel

This means that the current value of the newValue (as of this point in the code) is one. A few more steps forward, you will see yourself in an internal function that will be highlighted like this:

Highlighted internal functions

This means that the control is passed to the internal function _setCounter. Now you’ll see the previous Solidity locals have disappeared because they were local variables to the increment function and are not valid in _setCounter.

A few more steps, you will see your Solidity State panel changing the initial counter to the new value like this:

Solidity state counter one

At this point we can be sure that this specific line of code changed the state. That’s how you debug Solidity smart contracts! This was the very basic contract, so the debugging was quite easy. In comparatively bigger contracts, you might need to keep track of variables and state all of the time.

A few more debugging features

The following are a few more panels that might be useful to you:

Function Stack

You can get a lot of information from this panel, such as which function is currently under execution and which function called it. If there are multiple functions, it will be shown in a stack.

Global Variables

Global variables

You can keep track of the global variables in the transaction, just in case you need to know the sender or other data from the transaction.

Step Details

Step details

You can get some additional step data here, such as gas used and remaining gas.


List of OPcodes

Using the Opcodes, you can get advanced information about the current step of the contract. You can find out when the program performs steps like JUMP.


Knowing how to debug is important, and I’m sure this article gave you an idea on how to debug smart contracts in a proper way. You should still try to experiment with some complex programs, such as sending Ethereum through contracts and see how the flow works out.

: Full visibility into your web apps

LogRocket is a frontend application monitoring solution that lets you replay problems as if they happened in your own browser. Instead of guessing why errors happen, or asking users for screenshots and log dumps, LogRocket lets you replay the session to quickly understand what went wrong. It works perfectly with any app, regardless of framework, and has plugins to log additional context from Redux, Vuex, and @ngrx/store.

In addition to logging Redux actions and state, LogRocket records console logs, JavaScript errors, stacktraces, network requests/responses with headers + bodies, browser metadata, and custom logs. It also instruments the DOM to record the HTML and CSS on the page, recreating pixel-perfect videos of even the most complex single-page and mobile apps.


Categorized as news

By Nguyen Manh Cuong

Nguyen Manh Cuong is the author and founder of the nguyendiep blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.

Leave a comment

Your email address will not be published. Required fields are marked *