Ontology Developer Center
DISCOVERCOMMUNITYSUPPORT
  • Introduction
  • Discover Ontology
  • Getting Started
  • Glossary
  • Decentralized Identity and Data
    • ONT ID
      • Decentralized Identifiers
        • Method Specification for Ontology
        • Method Specification for Ethereum
        • Method Specification for BSC
      • Verifiable Credentials
        • Anonymous Credentials
      • ONT Login
        • Scenarios
        • Protocol Specification
        • Front-end JavaScript SDK
          • Integration and Usage
          • API Reference
        • Front-end UI SDK
          • Integration and Usage
          • API Reference
        • Back-end Go SDK
          • Integration and Usage
          • API Reference
        • Back-end Java SDK
          • Integration and Usage
          • API Reference
      • ONT TAG
        • Workflow
        • API Reference
      • Mercury
      • OScore
    • DDXF
      • Components and Interfaces
      • GREP
      • Overall Scheme
      • Solutions
        • Marketplace
          • Deployment
          • Scenarios
          • SaaS Tenant
          • Java SDK
        • Data Storage
          • Deployment
          • Java SDK
        • Resource Auditor
        • Offline Judge
      • Use Cases
        • E-Shops
  • ONTOLOGY ELEMENTS
    • Smart Contracts
      • Types of smart contracts
    • Token Protocols
    • Consensus Mechanism
    • Ontology Oracle
      • Oracle Process Flow
  • GUIDES & TUTORIALS
    • Development Guides
      • dApp Development
        • Using the dAPI
        • Data Synchronization
      • Smart Contract Development
        • EVM Contract
          • Development Environment and Tools
          • Wallet Setup
          • Contract Development
          • How to Deploy a Smart Contract with GetBlock
        • NeoVM Contract
          • Development tools and environment
          • Launching the IDE
          • Writing and editing program logic
          • Deploying and testing on private net
        • WASM Contract
          • Development Environment
          • Project Initiation - Hello World
          • Creating your own project
          • Development using SmartX
          • Runtime API
          • Contract Fundamentals
          • Inter-contract Interaction
          • Developing Contracts in C++
        • Publish Contract Source Code
    • Integration Guides
      • dApp Integration
        • dAPI Integration
          • Chrome Plugin
          • Mobile wallet dApp
          • QR code mechanism
          • Wake call mechanism
        • Cocos 2D-x
        • Unity 3D applications
      • Mobile Wallet Integration
        • SDK integration
        • dAPI Integration
          • In-wallet applications
          • QR code mechanism
          • Wake call mechanism
        • Stake
      • Using ONT ID
      • Exchange Integration
        • Exchange Docking Guide
        • Exchange API
      • Ontology for dApp Stores
    • EVM & Token Decimals Upgrade
  • ONTOLOGY NODE
    • Abstract
    • Node Deployment
      • Standard Node
      • Rosetta Node
    • Interacting with a Public Node
  • DEVELOPER TOOLS
    • dApp Development Framework
      • Punica CLI
      • Punica boxes
      • Solo Chain
    • IDE
    • APIs
      • HTTP API
        • Restful
        • WebSocket
        • Remote Procedure Call (RPC)
      • Explorer v2 API
        • Block
        • Address
        • Contract
        • Token
        • Transactions
        • ONT ID
        • Summary
        • Node
      • Native Token API
        • ONT Contract API
        • ONG Contract API
      • ONT ID Contract API
      • Web3 API
      • OScore Open API
      • Rosetta Node API
        • Data API
        • Construction API
      • DToken Contract API
      • DDXF
        • Marketplace Contract API
        • Storage API
      • Governance API
    • Digital Wallet
      • Chrome Plugin provider
      • Chrome Plugin dAPI
      • Mobile version provider
      • Mobile version dAPI
    • SDKs
    • Signing Server
      • Installation
      • API reference
  • COMMUNITY
    • Ecosystem Programs
    • Community Libraries
    • Community Events
    • Community Channels
    • Core Contributors
  • SUPPORT
    • FAQ
      • Basic blockchain concepts
      • Ontology Nodes
      • Ontology token protocols
      • Smart contracts
      • SDKs and APIs
    • Contact Us
Powered by GitBook
On this page
  • How to invoke a smart contract in SmartX
  • 1. Download and install solo-chain
  • 2. Install Cyano Wallet plugin in Google Chrome
  • 3. Accessing SmartX IDE
  • 4. Compiling and Deploying Smart contracts
  • 5. Migrating to MainNet

Was this helpful?

  1. GUIDES & TUTORIALS
  2. Development Guides
  3. Smart Contract Development
  4. NeoVM Contract

Deploying and testing on private net

Testing contracts on private net

PreviousWriting and editing program logicNextWASM Contract

Last updated 3 years ago

Was this helpful?

This brief tutorial will help you with private chain smart contract set-up, testing, and finally deployment on the MainNet.

There are certain tools that will be key to the process that follows-

  • SmartX - Ontology's online Smart contract IDE and debugger.

  • Solo-chain - A pre-built private chain.

  • Cyano wallet - Ontology's Google Chrome plug-in.

How to invoke a smart contract in SmartX

1. Download and install solo-chain

Solo-chain is a pre-built private chain. It encapsulates many different network communication and monitoring tools.

Set up solo-chain and verify whether it operates as configured. You can do this by checking the blocks that are currently being generated and the transactions that are taking place.

Please note down the IP address that is displayed in the control panel for future reference.

2. Install Cyano Wallet plugin in Google Chrome

Cyano wallet is a chrome integrated development program which allows developers to deploy and test smart contracts on the TestNet and MainNet.

Change the "Net" option to PRIVATE-NET, and paste the IP address copied from solo-chain (Under normal circumstances the address of the private node is 127.0.0.1). Save the settings by scrolling down and clicking the save button at the bottom.

For users with slower network speeds, the connection phase might take a few seconds.

Next, the private key is imported to the Cyano wallet from the solo-chain.

At the end, transactions can be initiated and the transaction fees can be drawn in ONG. The transaction fees here refer to the costs incurred during the testing and deployment phases of the smart contract respectively.

3. Accessing SmartX IDE

You can login to SmartX using your Cyano wallet .dat file if you're already registered, or you can login using Github.

Once logged in, you can create a new project. After selecting the new project option, you will be prompted to select a programming language.

Select the programming language of your choice. Next, a list of templates will appear. Select the template that is the most appropriate, or you can choose to choose the "Blank" option in case you want to start with a blank file. Give your file a name and proceed.

For simplicity, here we demonstrate the "Domain" template written in Python.

The next window that pops up is the main IDE that encapsulates editing, compilation, and testing of smart contracts into one convenient package.

4. Compiling and Deploying Smart contracts

Once you complete the editing process of your code, it can be compiled using the compile function that is accessible from the right hand side pane under the compile section. If the code is successfully compiled, a lot of useful information such as the AVM bytecode and the ABI details will be displayed on the bottom.

Next, you may proceed to deploy the contract.

Fill in the details and deploy the contract.

Using solo-chain, it can be confirmed whether or not the smart contract was successfully deployed. If the contract is deployed successfully you may then run it.

Under the run tab, the contract hash and a drop down list populated with the available functions can be accessed. The respective arguments in their corresponding data types can be passed through this pane.

The three operations over here can be used to perform the following functions-

  • Debug Run: can be used to verify whether the code works as intended within the local environment.

  • Pre-Run: can be used to invoke the query method, get the gas limit of the contract.

  • Run: the engine calls the smart contract and brings up the wallet, wherein the gas price can be set. Once confirmed, the transaction is authorized and the transaction fee is charged in ONG.

Every time the system returns a value or response, it will be displayed in the logs section. The return values are limited to hashes and hexadecimal values. There is a separate "Tool" section in the top right hand pane which facilitates conversion between different units and data types along with providing other useful functions.

The "Test" tab allows for multiple functions to be executed simultaneously. This allows for testing to mimic how the smart contract would actually function in real time when integrated into a dApp.

The "restful" tab refers to the restful API that Ontology employs as the link that allows for communication with nodes. Here we use it to fetch chain and transaction related information.

The collapsed result tab in the pop-up window includes detailed information with respect to the query. The tab can be expanded to reveal the information.

5. Migrating to MainNet

Once the testing phase completes, we can move on to deploying the smart contract on the MainNet.

Save the settings and your wallet will connect to the MainNet.

At this point, do ensure that your wallet has enough gas to further deploy contracts.

Next, you may return to SmartX and continue with the development process. The procedure to test and deploy the contracts does not change. Before you proceed, do confirm that the wallet's connection to the MainNet is still intact.

Install Cyano wallet and then in the main window click on the icon in the top right corner.

Once Cyano successfully connects to the private net, the icon at the bottom right corner of the wallet window will change to icon indicating that the connection has been successfully established.

We will use SmartX to develop, compile, and test smart contracts. Useful information regarding Smart contract development can be found .

Please note that deploying, running and testing contracts incurs gas cost and uses 0.01 units of ONG, and thus requires a certain amount of ONG balance to be present in your wallet. In case you don't have any, test tokens are available free of cost and can be applied for .

First, bring up the Cyano wallet and access settings by clicking on the cog in the top right hand corner.

here
here