Debugging from Visual Studio Code

Blockchain App Builder includes line-by-line debug support from Visual Studio Code for both TypeScript and Go projects.

To run line-by-line debugging:
  1. Open your chaincode project in VS Code Explorer. In the Chaincodes pane, right-click your chaincode and select Open in Explorer.
  2. Attach breakpoints to your code wherever necessary.
  3. Go to the Run menu and click Start Debugging. This attaches the debugger. It may take several seconds for the debugger to attach to the chaincode.
  4. Call any command from the Terminal which would execute your code.

    If you've been using the VS Code interface to test your chaincode so far, you can follow the invocation syntax outlined in Test Your Chaincode on a Local Hyperledger Fabric Network.

    The debugger will stop at your breakpoints. You can then start the debugging.

  5. Restart debugging to reflect new changes.

Since the chaincode is running in debug mode, the hot deployment of new changes does not happen automatically. You must manually restart the debugging process, using the debug controls in VS Code, in order to make the latest changes take effect.