Last time we introduced Ontology smart contracts. In this article, we will talk about SmartX, a one-stop IDE that can be used to compile, deploy, invoke, test, and debug smart contracts. It provides a range of smart contract templates and a powerful online editor. By reading this article, developers will know how to write, compile, deploy, and invoke smart contracts using SmartX.

Chapter 1: Create Project

Visit https://smartx.ont.io, then select your ONT ID file and enter your password to sign in as shown in the figure below. Developers can also use their GitHub account to log in.

After you have signed in, you will be directed to the project list page, where you can choose to open an existing smart contract project or create a new one.

Chapter 2: Write and Compile Smart Contracts

After you have created a new project, you can choose your preferred programming language to write a smart contract. Currently, C# and Python are supported. We recommend you to use Python smart contract since it has the most complete technical support. Then you enter the main editor page where the contract editor is in the middle, the running output is printed in the bottom, and the operation panel is on the right. Developers can start writing smart contracts in the editor, and there are many templates readily available.

After you finished writing your smart contract, you can click the Compile button on the operation panel to compile your code. If your code is correct, your smart contract will be compiled to the ABI and AVM file and will be displayed on the operation panel.

Chapter 3: Deploy Smart Contract

Next, you can deploy the smart contract on the Ontology blockchain by clicking the Deploy button, and Cyano Wallet will be invoked to sign and pay the required ONG amount. Deploying contract costs about 10 ONG. Cyano Wallet will be used to deploy and invoke the smart contract. See How to Use Cyano Wallet.

The result of the deployment will be printed in the output box. You can copy the results of the transaction hash to the Ontology blockchain browser to further confirm if the deployment is successful. In addition to SmartX, you can use the Ontology SDK to deploy a contract.

Chapter 4: Invoke Smart Contract

Finally, you can run the method of your contract. You can select the method you want to run, enter the correct parameter value, click the Run button, and invoke the smart contract. After you click the Run button, Cyano Wallet will be invoked to sign and confirm the transaction.

The result of the invocation will be printed in the output box. In addition to SmartX, you can use the Ontology SDK to deploy a contract.

Chapter 5: Conclusion

SmartX also provides a variety of tools that allow developers to exchange all types of data, such as converting the public key into an address and withdrawing private keys from Keystore.

In the future, SmartX will also support Ontology — WASM online compiler and more programming languages, including Java, Rust, Go, and JavaScript. SmartX will work like GitHub to be a distributed software project hosting platform. It will support multiple people to participate in and share a complex contract, and at the same time, implement a set of economic incentives and integrate fair governance policies to reflect the contributions of each participant, which will encourage smart contract writing, transaction, collaboration, community building, and the development of a valuable smart contract ecosystem.