Wake call mechanism
Applications wake the wallet service
Last updated
Applications wake the wallet service
Last updated
This section aims at providing a guide to how the wallet uses the wake up service to support login and contract invocation functionality.
For wallet implementation, please refer to the Cyano open source wallet Github repository. For application wake up call implementation, refer to this demo.
The two parties involved in this process are:
The dApp
: Blanket term that representsdApps
developed for the users of Ontology ecosystem.
The Provider
: Wallets that support dAPI
, and adhere to it's specifications.
dApp
data request URI scheme
:
dApp
sends the wake up call to the wallet.
Wallet receives the callback URL
the information to be verified. The user authenticates and signs, and the wallet invokes the dApp
back end's callback method.
dApp
back end verifies the signature.
dApp wakes the wallet
The wallet initiates a transaction, the user authenticates and signs, the wallet pre-executes the transaction, it is transmitted to the chain and finally the transaction hash
is returned to the callback
address.
dApp
back end can query the results of the transaction event using the transaction hash
.
The requests sent by the dApp to the wallet to perform login and contract invocation functions are illustrated below.
After URI and Base64 encoding, the structure of the request is as follows:
Field | Data type | Description |
action | string | Operation type |
type | string | Login method used, "ontid" if ONT ID is used to login and "address" when the wallet address is used to login |
dappName | string | Name of the dApp |
dappIcon | string | dApp icon resource link |
message | string | Randomly generated message for identity verification |
callback | string | Callback URL to send information to after the user carries out signature |
Wallet carries out the login process, URI and Base 64 encoding, signs the message, and sends the following message to the callback address using POST method:
Fields | Data type | Description |
action | string | Operation type |
params | string | The parameters needed by methods |
type | string | Login method used, "ontid" if ONT ID is used to login and "account" when the wallet address is used to login |
user | string | Identifier of the account that is used for signature, say a wallet address or ONT ID |
message | string | Randomly generated message for identity verification |
publickey | string | Account public key |
signature | string | Account digital signature |
Success response after signature verification-
Failure response after signature verification-
The signature protocol is essentially the same as login, only that the dApp name and icon need not be passed. The dApp
sends a request with the following data, after URI
and Base64
encoding:
Field | Data type | Description |
action | string | Operation type |
type | string | Set to "ontid" if the login method is ONT ID, and "address" if the wallet address is used, set to "address" by default if nothing is specified |
message | string | Generated randomly, used for identity verification |
The wallet's response to the login request, sent after URI
and Base64
encoding is of the following form-
The data structure of the wake call that is sent to the wallet after URI and Base64 encoding is as follows:
A Base58
address, for e.g., AUr5QUfeBADq6BMY6Tp5yuMsUNGpsD7nLZ
__can be used to fill the %address
parameter. The wallet converts the %address
to the wallet's asset address. If the argument contains the %ontid
, the wallet converts it to the wallet's ontid
address.
The notify
result returned after pre-execution can be used to find out the token expended by the user in the particular transaction. (ONT/ONG)
The Notify
message needs to be parsed to make a judgement, because a transaction may have multiple transfer or smart contract events. If the other contract events don't need to handled, then the nature of transferred tokens can be judged from the address i.e. ONT/ONG
and the transfer
method along with the sender.
Signature verification methods | Transaction event query methods | Cyano Wallet | dAPI - Mobile provider SDK | dAPI - Mobile client SDK |