Course07: How to Use VSCode Extension
At 2018-11-14 By zhaoyue

How to Use VSCode Extension

Version 0.1

1. What is VSCode Extension for Ontology

Visual Studio Code combines the simplicity of a source code editor with powerful developer tooling, like IntelliSense code completion and debugging.

Before start, please check you have download VSCode.This extension adds support for development and testing of smart contracts on Ontology blockchain. And please disable pylint when VSCode recommends it to you.

Features: 1. Compile: VSCode supports Python smart contracts (.py) and CSharp smart contracts (.cs). 2. Deploy: Deploy smart contracts to MainNet / TestNet/ PrivateNet. 3. Invoke: Execute or pre-execute a smart contract. 4. Debug: Support debug procedure (StepIn, StepOut, Next, Continue, Stop, Restart), setting breakpoints, variables preview and set, and state store manipulation.

2. Extension Settings

This extension contributes the following settings:

  • specifies which network will be used during deployment and invocation
  • PrivateNet address in the form of http://host:port
  • ontology.wallet: wallet file used during deployment and invocation (you can use \${workspaceFolder} in the path)
  • ontology.payer: default payer address (must be found in wallet file)
  • ontology.deploy.gasLimit: gas limit used during deployment
  • ontology.deploy.gasPrice: gas price used during deployment
  • ontology.invoke.gasLimit: gas limit used during invocation
  • ontology.invoke.gasPrice: gas price used during invocation

Those settings can be changed in standard VSCode settings by clicking the gear box icon in lower left corner.

Settings 1 Settings 2

3. How to use Ontology extension?

Go to extensions market first, and then find and install the VSCode Extension for Ontology extension. Open any .py or .cs file in VS Code. The extension is now activated. This extension enhances the whole Smart contract development process.

3.1 Compile

To compile a smart contract, show context menu on any .py or .cs file.


Press Compile smart contract. You will be notified about the outcome of compilation through notifications. The compilation will produce compiled code in .avm file and smart contract description file in _abi.json file, both in build folder.

3.2 Deploy

To deploy a smart contract, show context menu on compiled .avm file.

Deploy 1

Press Deploy smart contract. A new panel with description form will show up. Enter the necessary information and press Deploy. You will be notified about the outcome of compilation through notifications.

3.3 Invoke & Debug

To invoke a method in the smart contract, opening the _abi.json file. A new panel with smart contract methods will show up.

Invoke 1

Double click on any of the methods to show invocation form. Fill out all the parameters and click the invoke button.

Invoke 2 Invoke 3

You will be notified about the progress of invocation through notifications and a new panel with invocation result will show up.

Invoke 4

If you want to debug a smart contract instead of invocation, pressing the Debug button. You can use standard debug features of VSCode like StepIn, StepOut, Next, Continue, Restart, Stop and breakpoints together with variables preview and set.

One more thing


git clone

OEP-4 smart contract

Extension author

Please feel free to give any suggestion
Contact: Yue Zhao 
Wechat: 16621171248