JS Extensions
JSBridge is injected javascript code in MYKEY dapp browser enviroment by default, which support Scatter protocol, and web3js protocol.
In order to control the MYKEY application conveniently, MYKEY adds the following methods:
Method
Description
Check whether the current wallet is MYKEY
Close App window and return to MYKEY
Open full screen
Close full screen
Disable physical back button(Android Only)
Allow physical back button(Android Only)
Get MYKEY Account Information
Get client configuration
Send transaction
Apply MYKEY sign transactions
Set application title
Show loading animation
Hidden loading animation
serialize specified function call
Check whether the current wallet is MYKEY
window.ethereum.isMYKEYClose App window
Close App window and return to MYKEY.
window.MyKey.Browser.closeWindowOpen full screen
Open full screen
window.MyKey.Browser.openFullScreenParams
Param
Type
Description
isLandscape
boolean
true(Landscape)
fasle
Close full screen
Close full screen.
window.MyKey.Browser.closeFullScreenDisable physical back button
Disable physical back button, only for Android
window.MyKey.Browser.forbidPhysicalBackAllow physical back button
Allow physical back button, only for Android
window.MyKey.Browser.allowPhysicalBackGet MYKEY Account Information
Get MYKEY Account Information
window.MyKey.Browser.getAccountInfoParams
Param
Type
Description
openChain
string
true|fasle
true: open creating page if no chains for an account
Return
Return format: Promise
{
"data": {
"accountName": "", //Nickname in MYKEY
"chainInfoList": ["account": "", "chain": ""],
"id": "", //unique id in MYKEY
"operationKeys": ["","",""], //public keys of three operation keys
"xpubOperationKeys": ["","",""] //public keys of three operation keys in Xpub format
},
"errorCode": 0
}Get client configuration
Get client configuration
window.MyKey.Browser.getClientConfigReturn
Return format: Promise
{
"data": {
"currency": "CNY",
"locale": "zh-CN",
"maxKycBindAccount": 1,
"regioin": "CN",
"userAgent": "", //include field channel:MYKEY
"recaptchaUserKey":"" //only use for MYKEY redpackage
},
"errorCode": 0
}Send transaction
Send transaction
window.MyKey.Browser.sendTransaction(transaction) => PromiseParams
Param
Type
Description
transaction
string
Specify chain and actions
Return
Return format: Promise
result: {
"errorCode": 0,
"errorMsg": "",
"data": {
"transactionId": "",
"signature": ""
}
}Example:
Buy ram on EOS.
window.MyKey.Browser.sendTransaction('{"actions":[{"account":"eosio","name":"buyram","data":{"payer":"","receiver":"","quant":"1.0000 EOS"}}],"chain":"EOS"},"extra":{"key":"value"}}')New field extra will be effected from Android:2.5.0,IOS:2.5.0
Sign
Apply MYKEY sign transactions
window.MyKey.Browser.sign(message) => PromiseParams
Param
Type
Description
message
string
unsigned message
Return
Return format: Promise
result: {
"errorCode": 0,
"errorMsg": "",
"data": {
"signature": ""
}
}Get Transaction Progress
window.MyKey.Browser.getTransactionProgressParams
Param
Type
Description
chain
string
EOS|ETH
transactionId
string
blockNum
int
blockNum, optional
Return
Return format: Promise
result: {
"errorCode": 0,
"errorMsg": "",
"data": {
"percent": , //[0 - 100]
"blockNum": //[blockNum]
}
}Effective from: Android:2.5.0,iOS:2.5.0
Set application title
Set application title
window.MyKey.Browser.setTitle(title)Params
Param
Type
Description
title
string
application title
Show loading animation
Show loading animation
window.MyKey.Browser.showLoadingHidden loading animation
hidden loading animation
window.MyKey.Browser.hiddenLoadingserialize specified function call
serialize specified function call
window.MyKey.Browser.encodeFunctionCall(abi, method, param) => PromiseReturn
result:{"errorCode":0,"errorMsg":"","data":"[serialized data]"}
Params
Param
Type
Description
abi
string
abi for the function, type string, eg:"[{\"constant\":false,\"inputs\":[
{\"name\":\"_to\",\"type\":\"address\"},{\"name\":\"_value\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"name\":\"\",\"type\":\"bool\"}],\"payable\":false,
\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]"
method
string
method name, type string, eg:transfer。
param
string
params, eg:{_to:"0xc4ED1B3f31acadbE3c14B20fA766B6C4B1FAB208",
_value:"20000000000000000000"}
Last updated
Was this helpful?