dAPI Integration

Integrating a mobile wallet using the dAPI

Integrating the dAPI is practically equivalent to integrating the Provider SDK. The Provider SDK encapsulates methods for iOS/Android webview, and supports communication between web based dApps and iOS/Android webview.

For the dAPI method handbook for both Android and iOS operating systems, please follow this link.

dAPI usage scenarios

Mobile version of dAPI can allow the wallet to perform the following features based on dApp scenarios-

  • dApps are launched in the wallet

  • Wallet scans QR codes

  • Applications wake the wallet

dApps open in the wallet

The execution process is as follows:

  1. The dApp is opened in the wallet

  2. Account or identity information is fetched

  3. dApp logs in

  4. dApp invokes smart contract

Wallet scans a QR code

Login Process

The execution process is as follows:

  1. Wallet scans the QR code provided by the dApp

  2. Provider receives the callback URL and verification message, user authenticates and signs the message, the message is sent to the callback URL provided.

  3. dApp back end carries out the verification process for the message.

Invoking a smart contract

The execution process is as follows:

  1. Wallet scans the QR code provided by the dApp

  2. Wallet initiates the transaction, the user authenticates and signs, the contract is pre-executed, user confirms, transaction is transmitted to the blockchain, transaction hash is returned to the callback address

  3. dApp back end queries transaction event

dApp wakes the wallet

dApp sends a login request

  1. dApp sends the wake call to the wallet

  2. Wallet fetches the callback URL and the verification message, user enter authenticates and signs the message, wallet returns the signature to the callback address

  3. dApp back end verifies the message

dApp sends an invocation request

  1. dApp sends the wake call to the wallet

  2. Wallet initiates the transaction, the user authenticates and signs, wallet pre-executes the transaction, the transaction is transmitted to the blockchain, the transaction hash is returned to the callback address

  3. dApp back end queries the transaction event on the blockchain using the transaction hash

Demonstration

Here is a basic demonstration of some of the basic functions that the wallet can perform. A demo wallet which can be downloaded using the link below has been used to mimic a second party.

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

Cyano wallet source code(Android): https://github.com/ontio-cyano/cyano-android

Cyano wallet source code(iOS): https://github.com/ontio-cyano/cyano-ios

After completing the installation of Cyano wallet and the demo app, features of both the wallets can be tested along with the source code as reference.

Transactions can be performed to test smart contract logic and confirming whether or not the platform has been integrated successfully.

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/#/

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.

Last updated