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
- Up-to-date installation of the IntelliJ (or WebStorm) IDE Ultimate Edition (Paid Version)
- The IntelliJ Solidity plugin
- NPM
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
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