Published in


The Latest Version of SmartX is Now Available!

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/lib.rs file

Note: The above contract contains three methods:

  • fn add(a: U128, b: U128) -> U128
    Return the sum of A and B;
  • fn hello() -> String
    Return “hello world”;
  • fn say(data: &str) -> String
    Return “say”.to_string() + data;

Step 3: Compile and optimize contracts

The build.sh 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;
  • rust_wasm_contract_template.wasm.strIs is the hex encoding of Wasm bytecode;
  • rust_wasm_contract_template.wasm.wast is the Wasm contract in .wast format.

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
  • When deploying and calling, you must first confirm whether the Ontology network connected in Cyano Wallet is updated (currently the test network is supported with main network support coming soon)
  • When deploying and calling, ensure your ONG balance is adequate to cover the commission for deploying and calling contracts.

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.




Ontology is a high performance, open source blockchain specializing in digital identity and data. ONTO: http://onto.app/downloadpage/TW Telegram: http://t.me/OntologyNetwork

Recommended from Medium

Will Helium HNT Mining Be Productive In 2022?

THEKEY MVP/Testnet Progress Report

[CODEOS] Essential knowledge in EOS contact development

How Spheron (previously ArgoApp) plans to educate about the benefits of blockchain and…

A Deep Dive into the Oasis Network


Triall Product Spotlight: Wearable Integration

Crypto wallets (smart contract perspective) and multi-sig wallet

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
The Ontology Team

The Ontology Team

Active project domain: https://ont.io/

More from Medium

Weekly Development Update 46 & 47

A Pivotal Shift in the DEX Environment

Datapolis Dapp is Live in Beta Version — Built with the DataX Protocol

Post AMA | Telegram AMA with Champion Hunters Chief of Operations Jun