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
  • Fundamental concepts
  • Role of dApps
  • Role of mobile wallets
  • Interaction Process
  • Login scenario
  • Smart Contract invocation scenario
  • dAPI protocol usage
  • 1. Installation
  • 2. Import
  • 3. Initialization
  • 4. Method Usage
  • Code base for Reference

Was this helpful?

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

Mobile wallet dApp

Launching the dApp inside the mobile wallet

PreviousChrome PluginNextQR code mechanism

Last updated 5 years ago

Was this helpful?

Considering the current scenario, mobile wallets are an important channel of access to dApps. After integrating Ontology's cyano-bridge package, the developer can implement and invoke dAPI that adheres to OEP-1 standards, and can communicate with any wallet dApp that integrates the Provider SDK to carry out chain-related operations.

Details regarding the OEP-1 protocol can be found .

Fundamental concepts

Let us take a look at the processes that distributed technologies such as dApps and mobile wallets carry out.

Role of dApps

The dApp back end primarily carries out the following tasks:

  • dApp operations, i.e., generating the relevant login parameters, or the parameters for invoking smart contracts.

  • Synchronizing with the on-chain data, and fetching the results of login, or smart contract invocation.

Role of mobile wallets

A mobile wallet acts as a provider. It carries out the roles that involve interacting with the chain, such as providing the signature data, pre-executing and executing transactions, etc.

The above description is with respect to the wallets that can serve as providers. Currently, the following are supported:

Interaction Process

Generally speaking, application users' primary concerns are the login and transaction procedure.

The process flow is illustrated in the following figure:

Login scenario

  1. A dApp is opened in the wallet's dApp store.

  2. Next, there are two possible circumstances - either the dApp sends an account query request to the wallet, and the wallet returns the asset account's address, or the dApp sends a login request to the wallet and the wallet returns signature data.

  3. If the dApp verification is completed, access is granted.

Smart Contract invocation scenario

  1. The dApp sends an invocation request to the wallet.

  2. The wallet digitally signs the transaction, pre-executes it, sends it to the chain, and returns the transaction hash to the dApp.

dAPI protocol usage

1. Installation

Based on subjective requirements, one of the following two methods can be chosen to install cyanobridge.

npm installation-

npm install cyanobridge

CDN installation-

Currently, the latest version can be acquired using jsDelivr. Paste the following script on the page's code to instantly start using the dAPI.

<script src="https://cdn.jsdelivr.net/npm/cyanobridge/lib/browser.min.js"></script>

CDN users are advised to fix the version in the above link so as to avoid compatibility issues during updates.

2. Import

CommonJS

var client = require('cyanobridge').client

ES6 module

import { client } from 'cyanobridge'

Web Page Embed

To import the browser.js file inside the ./lib directory:

<script src="./lib/browser.js"></script>

var client = CyanoMobile.client;

3. Initialization

The dAPI needs to be initialized and registered before being used.

import { client } from 'cyanobridge'
client.registerClient();

4. Method Usage

Fetch account or user identity information

dApp information is optional. The developer may choose not to fill it when making the function call.

import { client } from 'cyanobridge'

const params = {
​    dappName: 'My dapp',
​    dappIcon: '' // some url points to the dapp icon
}

try {
​    const res = await client.api.asset.getAccount(params);
    const res = await client.api.identity.getIdentity(params);
​    console.log(res)
} catch(err) {
​    console.log(err)
}

Login

Login is signed on the wallet's end. The dApp carries out the verification signature.

const params = {
    type: 'account',// account or identity that will sign the message
    dappName: 'My dapp', // dapp's name
    dappIcon: 'http://mydapp.com/icon.png', // the URL that points to the dapp's icon resource
    message: 'test message', // message sent from dapp that will be signed by native client
    expired: new Date('2019-01-01').getTime(), // expiry date of login
    callback: '' // callback url of dapp
}
let res;
try {
    res = await client.api.message.login(params);
    console.log(res)
}catch(err) {
    console.log(err)
}

Invoke contract or initiate payment

const scriptHash = '8b344a43204e60750e7ccc8c1b708a67f88f2c43';
const operation = 'transferOng'
const args = [
   {
        "name": "arg0-id",
        "value": "String:hedgsg"
    }, {
        "name": "arg1-from",
        "value": "Address:AecaeSEBkt5GcBCxwz1F41TvdjX3dnKBkJ"
    }, {
        "name": "arg2-to",
        "value": "Address:AUr5QUfeBADq6BMY6Tp5yuMsUNGpsD7nLZ"
    }, {
        "name": "arg3-int",
        "value": 1
    }
]
const gasPrice = 500;
const gasLimit = 20000;
const payer = 'AecaeSEBkt5GcBCxwz1F41TvdjX3dnKBkJ'
const config = {
​    "login": true,
​    "message": "invoke smart contract test"
}
const params = {
          scriptHash,
          operation,
          args,
          gasPrice,
          gasLimit,
          payer,
          config
        }
try {
   const res = await client.api.smartContract.invoke(params);
   } catch(err) {
​    console.log(err)
}

Error codes

This is the list of error codes that the system returns.

Error Code

Description

0

Success

80001

Params error

80002

Method error

80003

Internal error

An example of the code returned (JSON):

{
    "action": "login",
    "error": 0,
    "desc": "SUCCESS",
    "result": true
}

Code base for Reference

Signature verification methods

Transaction event query methods

Cyano Wallet

dAPI - Mobile provider SDK

dAPI - Mobile client SDK

here
ONTO
Cyano Wallet
O-Wallet
Math Wallet
Banko
Huobi Wallet
Java SDK
Java SDK
Cyano - Android
Cyano - Android SDK
Cyano Bridge
TypeScript SDK
TypeScript SDK
Cyano - iOS
Cyano - iOS SDK