Debugging Solidity Smart Contracts Inside of the IntelliJ IDE

80Trill
3 min readJun 9, 2018

--

This article shows how to set up the IntelliJ (You can also use WebStorm as they are interchangeable for the purposes of this tutorial) debugger when programming Solidity.

Currently when it comes to debugging smart contracts in Solidity, developers may use remix.ethereum.org or other means to test and debug their code. Unfortunately we are rarely coding our entire project in remix. With some simple Intellij configurations we have found a way to debug Truffle Javascript test suites inside of the IDE. This will allow developers to use Intellij’s built in debugger, instead of repeatedly switching back and fourth between the IDE and the Terminal or whatever your process happens to be.

Example

The following instructions will allow you to run a small test suite for demonstration purposes. It is highly recommended that those unfamiliar with the Truffle Framework, IntelliJ IDE, or basic Solidity functionality, familiarize themselves before proceeding.

Prerequisites

The Files

Clone the following Git Repo

https://github.com/80Trill/truffle-intellij-debug

Navigate to the project root and install the dependencies via NPM.

npm install

There is a directory located which contains the scripts used to run the debugger. As well as a modified “truffle-config.js”.

"truffle-intellij-debug/scripts/setup.sh"
"truffle-intellij-debug/scripts/test.sh"

"truffle-intellij-debug/truffle-config.js"

Applying the Settings/Running the Debugger

1) Inside of edit configurations, you will need to create a new run/debug configuration
2) Setting up an external tool
3) Ensure that external tool “start testrpc” has Program -> Setup.sh, and Working Directory -> truffle-intellij-debug
(The relative paths where they are saved on your computer)
4) After running the configuration
5) Run the debugger with the following breakpoints and examine how it works
6) Debugger Console output

If you followed the instructions you should be able to set breakpoints and run the solidity code in debug mode which should prove very helpful!

There is certainly room for improving on the setup, but for now this will open the door for improving the development process for Solidity Smart Contracts.

— T. Riley Schwarz

riley@80trill.com

--

--

80Trill

A blockchain consulting company specializing in smart contract writing, auditing, and advising.