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
  • Primary Functionality
  • Integration Options
  • dAPI Compatibility
  • Wallet Demonstration
  • 1. Open a dApp in the wallet
  • 2. Fetch Account or Identity Information
  • 3. Login into the dApp
  • 4. dApp Contract Deployment

Was this helpful?

  1. GUIDES & TUTORIALS
  2. Integration Guides
  3. dApp Integration

dAPI Integration

General integration methods and functionalities

Primary Functionality

From a developer's point of view, the functions that facilitate interaction with the Ontology blockchain can be broadly categorized as follows:

  • Login: Allows user identity verification, and querying account or identity related information

  • Transactions: The transaction service for both ONT and ONG, or the other OEP token related transactions can be carried out by deploying smart contracts. An example of an ONG based transaction-

OntCversion = '2.0.0'
from ontology.interop.Ontology.Native import Invoke
from ontology.builtins import state
from ontology.interop.System.Runtime import Notify
from ontology.interop.System.ExecutionEngine import GetExecutingScriptHash
from ontology.interop.Ontology.Runtime import Base58ToAddress,AddressToBase58


# ONG Big endian Script Hash: 0x0200000000000000000000000000000000000000
OngContract = Base58ToAddress("AFmseVrdL9f9oyCzZefL9tG6UbvhfRZMHJ")


def Main(operation, args):
    if operation == "transferOng":
        if len(args) != 3:
            return False
        return transferOng(args[0], args[1], args[2])

    return False

def transferOng(from_base58, to_base58,  ong_amount):
    from_acct = Base58ToAddress(from_base58)
    to_acct = Base58ToAddress(to_base58)
    param = state(from_acct, to_acct, ong_amount)
    res = Invoke(0, OngContract, "transfer", [param])
    if res and res == b'\x01':
        Notify([True,from_base58, to_base58,  ong_amount])
        return True
    else:
        Notify([False,from_base58, to_base58,  ong_amount])
        return False

Integration Options

Keeping in mind the different circumstances and scenarios that the developers might be working with, Ontology provides multiple ways to integrate the platform into a dApp.

  • The multiple decentralized methods that use the dAPI, including the option to open a dApp from within a mobile wallet, and the Cyano wallet chrome plugin, all allow the dApp to interact with the blockchain.

  • Integrating using one of the multiple SDKs, a method which is also decentralized at its core. For example, games that use the Unity 3D engine and C#. would encounter the need to integrate through the respective SDKs.

  • Making the application open-platform using the ONT ID. Though, this method is not completely decentralized.

No matter which one of the above methods you choose to integrate your dApp, the login feature and the ability to deploy smart contracts remains constant and unaffected. Therefore, developers can freely choose any of the method to integrate dApps.

As discussed above, there are two technically decentralized dApp integration methods, both of which offer the same functionality in every way. The choice rests with the developer.

To satisfy that the requirement for dApps to be accessible on both the browser and the mobile version, here we provide examples that involve using dAPI in three different scenarios. You can refer to:

dAPI Compatibility

Unlike traditional apps, a dApp doesn't have a centralized back end platform that manages accounts. The user maintains full possession and control of their identity and assets. That is the reason why apart from building the app's logic using smart contracts, dApps need to employ various means to interact and communicate with the blockchain.

To bring down the difficulty level of dApp development, Ontology provides plenty of dAPI methods for developers to use and allow dApps to communicate with the blockchain. Ontology's current framework and technology is compatible with, and can run a dApp on virtually any mainstream device.

Currently, the following scenarios are supported-

  • dApp invokes the Chrome wallet plugin

  • dApp launched from within the mobile wallet

  • The mobile wallet scans QR codes to execute smart contracts

  • Application wakes the mobile wallet

Wallets that already support dAPI protocol-

  • Math wallet

  • Banko

  • Huobi wallet

The dApps that are currently using dAPI can be found by following the below link-

To ensure that the requirement for dApps to be accessible on both the browser and the mobile version, here we provide examples that involve using dAPI in three different scenarios. You can refer to:

Wallet Demonstration

The most common method of launching a dApp from within the wallet is illustrated here. The process and a few basic functions are demonstrated below.

After completing the installation of Cyano wallet, you can test your dApp by performing transactions through the demo app.

1. Open a dApp in the wallet

You can also input your local address where you have deployed your dApp to open your own app.

2. Fetch Account or Identity Information

Clicking on the Get Identity button will directly fetch the ONT ID of the account. Enter the password when prompted and the ID will appear in the blank field below. You can carry out the authorization/KYC by uploading your document information, for e.g, passport number, picture of the first page, etc.

3. Login into the dApp

In case there is a need to verify the user's identity, dApp sends a message to the wallet to carry out the signature process, and then verifies the signature.

As illustrated above, the wallet prompts the user to enter the password. Once confirmed, the contract related details can be accessed.

4. dApp Contract Deployment

The contract deployment process involves the following steps:

  1. After the signature verification is completed successfully, the contract is pre-processed.

  2. The user confirms and transmits the transaction via the wallet.

  3. The hash value of the transaction is returned to the dApp.

There are 2 advantages of using the the dAPI integration method-

  • The user can maintain possession of the assets and data.

  • The wallet login dApp can be readily integrated and conveniently used.

PreviousdApp IntegrationNextChrome Plugin

Last updated 5 years ago

Was this helpful?

Smart contract development: As far as the vast majority of dApps are concerned, logic implementation either relies completely, or at least in part, on smart contracts. Considering games, for instance, functions such as buying, selling, renting, or generating random numbers, etc. can conveniently be implemented using smart contracts. For more details on smart contracts, feel free to check out.

Tokenizing assets: Developers always have the option to tokenize and issue many different types of assets, such as OEP4, OEP5, OEP8, etc. For a more detailed explanation of the aforementioned assets, refer to .

Mobile version dAPI implementation -

Chrome plugin wallet dAPI implementation -

Example dAPI code compatible with both the Chrome plugin and the mobile version -

Mobile version dAPI implementation -

Chrome plugin wallet dAPI implementation -

Example dAPI code compatible with both the Chrome plugin and the mobile version -

H5 demo dApp source code:

H5 demo dApp link:

Cyano wallet mobile version (Android):

Launch Cyano wallet and access the "DApp" section. Open the "PRIVATE APPS" tab and input this address to access the demo dApp:

For detailed information on the integration protocol, please follow link.

this
this
dAPI for mobile
dAPI for chrome
dAPI-universal
dAPI for mobile
dAPI for chrome
dAPI-universal
https://github.com/ontio-cyano/mobile-dapp-demo
http://101.132.193.149:5000/#/
http://101.132.193.149/files/app-debug.apk
http://101.132.193.149:5000/#/
this
LogoGitHub - ontio-community/dapp-store: dapp-storeGitHub