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
andONG
, or the otherOEP
token related transactions can be carried out by deploying smart contracts. An example of anONG
based transaction-
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 this 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 this.
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 adApp
from within a mobile wallet, and theCyano
wallet chrome plugin, all allow thedApp
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 theUnity 3D
engine andC#
. would encounter the need to integrate through the respectiveSDKs
.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:
Mobile version
dAPI
implementation - dAPI for mobileChrome plugin wallet
dAPI
implementation - dAPI for chromeExample
dAPI
code compatible with both the Chrome plugin and the mobile version - dAPI-universal
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:
Mobile version
dAPI
implementation - dAPI for mobileChrome plugin wallet
dAPI
implementation - dAPI for chromeExample
dAPI
code compatible with both the Chrome plugin and the mobile version - dAPI-universal
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.
H5 demo dApp source code: https://github.com/ontio-cyano/mobile-dapp-demo
H5 demo dApp link: http://101.132.193.149:5000/#/
Cyano wallet mobile version (Android): http://101.132.193.149/files/app-debug.apk
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
Launch Cyano wallet and access the "DApp" section. Open the "PRIVATE APPS" tab and input this address to access the demo dApp
: http://101.132.193.149:5000/#/
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:
After the signature verification is completed successfully, the contract is pre-processed.
The user confirms and transmits the transaction via the wallet.
The
hash
value of the transaction is returned to thedApp
.
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.
For detailed information on the integration protocol, please follow this link.
Last updated