dAPI Integration
Integrating a mobile wallet using the dAPI
Last updated
Integrating a mobile wallet using the dAPI
Last updated
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.
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
The execution process is as follows:
The dApp
is opened in the wallet
Account or identity information is fetched
dApp
logs in
dApp
invokes smart contract
The execution process is as follows:
Wallet scans the QR code provided by the dApp
Provider receives the callback URL
and verification message, user authenticates and signs the message, the message is sent to the callback URL
provided.
dApp
back end carries out the verification process for the message.
The execution process is as follows:
Wallet scans the QR code provided by the dApp
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
dApp
back end queries transaction event
dApp
sends the wake call to the wallet
Wallet fetches the callback URL
and the verification message, user enter authenticates and signs the message, wallet returns the signature to the callback address
dApp
back end verifies the message
dApp
sends the wake call to the wallet
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
dApp
back end queries the transaction event on the blockchain using the transaction hash
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.
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/#/
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.
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.
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 the dApp
.