-
Notifications
You must be signed in to change notification settings - Fork 23
Using the VSCode Solidity Debugger
Matthew Little edited this page Nov 8, 2018
·
5 revisions
- .NET Core SDK (>2.1.4)
- Visual Studio Code (>1.27)
- Solidity Debugger Extension for VSCode
- Ensure no Folders or Workspaces are opened in VSCode and open your
.sol
file. - The contract must define a parameterless constructor function (so that it can be automatically deployed).
- This constructor function can call other functions in your contract.
- When debug is started the contract is deployed and its constructor function will be ran. Any breakpoints set in the constructor or functions that it calls will be hit.
- Open the folder containing
.sol
files with VSCode. - Define a contract titled
Main
with a parameterless constructor function. - This entry point contract can deploy your other contract(s) in its constructor function.
- When debug is started the
Main
contract is automatically deployed and its constructor function will be ran.
First, follow the quick guide to setting up a Solidity test project using Meadow.
https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp
- Open your project in VSCode and select the debug panel (located on the left vertical menu bar).
- At the top left debug dropdown (next to the green play button), select "Add Configuration..."
- Inside the
.vscode/launch.json
file, add the following configuration:
{
"version": "0.2.0",
"configurations": [
{
"type": "solidityMeadow",
"request": "launch",
"name": "Debug Solidity (via unit test run)"
}
]
}
Open a .sol source file from your contracts
directory and set breakpoints in a function that gets executed by your C# unit tests.
Select the debug panel again, ensure the correct configuration is selected, and click the green play button.
The unit tests will be executed and your breakpoint will be hit.