The Latest Version of SmartX is Now Available!

The Ontology Team
Dec 15, 2019 · 5 min read

We are delighted to announce that the latest version of SmartX is now available. SmartX now fully supports Wasm contracts, which are now live on the Ontology MainNet. In order to further the cause of global developers, the latest version of SmartX now supports the deployment and call of Wasm contracts. For further information, read below.

1. Generating and Testing Contracts

Before introducing how to deploy and invoke Wasm contracts with SmartX, let’s have a look at how to develop a simple testing contract using the Wasm contract template. For a detailed tutorial on developing Ontology Wasm contracts, please refer to:

Step 1: Clone the contract template

Step 2: Modify the src/ file

Note: The above contract contains three methods:

  • fn add(a: U128, b: U128) -> U128
    Return the sum of A and B;

Step 3: Compile and optimize contracts

The script encapsulates the function of compiling and optimizing contracts, which can be executed directly.

The bytecode file generated by compilation is placed in the generated output folder. The directory structure is as follows:

  • rust_wasm_contract_template.wasm is the Wasm bytecode file required for testing SmartX;

2. Deploying Contracts

Firstly, users have to log onto SmartX and then enter the Project List page. On this page, click the Open Wasm file button.

Enter the name of Wasm smart contract and choose the rust_wasm_contract_template.wasm file generated above. Click the confirm button, which will lead to a project of Wasm contract, for better management in the future.

After opening the newly created Wasm contract project, the bytecode of the Wasm contract was shown in the area of contract editing. The bytecode in this part can be replaced.

Next step, it is time to deploy the Wasm contract. This step is no different to that of deploying a NeoVM contract. Fill the related information in the right deploy tool page, and click the deploy button, the Chrome plug-in wallet Cyano Wallet (which should be installed to the most updated version in advance) will be called, and users will be asked to fill in the wallet password. If there is enough ONG in Cyano Wallet, the Wasm contract will be deployed to Ontology network after a short period. You can click Apply ONG as shown on the below image to apply for ONG on TestNet.

3. Calling

After successful deployment, you will encounter the Run page of the contract. Here we can call the Wasm contract.

We need to enter the name of the function to be called add, add the parameters required for the function, select the correct type for the parameter, and enter the parameter value. The add function requires two data types of u128. The u128 in the contract corresponds to the Long type in SmartX, so the parameter type should be Long. Then choose either pre-execute or run button. The result of the contract execution will be displayed in the log area on the lower left-hand side. You only need to click on pre-execution, because data on the chain will not yet be updated, and the printed result in log area is hex encoding, which is used to decode.

Now that we have completed the deployment and invocation of Wasm contracts on SmartX, let’s dive into the call of hello and say functions. The hello function just returns the “hello world” string therefore no parameters need to be entered. Check the call screenshot as follows:

The method of say results in adding the prefix ”say” to in-parameters and return. Parameters of type & STR are required. Type & STR parameters in the contract correspond to type string on SmartX. The call example is as follows:


In this article, we have used an example to briefly introduce the main process of deploying and invoking a Wasm contract on SmartX. Note the following points:

Before use, the following preparation is required:

  • You must open SmartX in the Chrome browser and install Ontology’s plug-in wallet: Cyano Wallet

Are you a developer? Make sure you have joined our tech community on Discord. Also, take a look at the Developer Center on our website, there you can find developer tools, documentation, and more.


A high-performance public blockchain and distributed collaboration platform. Telegram: || ONTO:

The Ontology Team

Written by

Active project domain:


A high-performance public blockchain and distributed collaboration platform. Telegram: || ONTO:

More From Medium

More on Blockchain from OntologyNetwork

More on Blockchain from OntologyNetwork

Ontology Weekly Report (March 17–23)

More on Blockchain from OntologyNetwork

More on Blockchain from OntologyNetwork

#MyFirstNFTonONTO# Campaign

More on Blockchain from OntologyNetwork

More on Blockchain from OntologyNetwork

Multi-VM in Ontology 2.0:

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade