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.isMYKEY

Close App window

Close App window and return to MYKEY.

window.MyKey.Browser.closeWindow

Open full screen

Open full screen

window.MyKey.Browser.openFullScreen

Params

Param

Type

Description

isLandscape

boolean

true(Landscape)

fasle

Close full screen

Close full screen.

window.MyKey.Browser.closeFullScreen

Disable physical back button

Disable physical back button, only for Android

window.MyKey.Browser.forbidPhysicalBack

Allow physical back button

Allow physical back button, only for Android

window.MyKey.Browser.allowPhysicalBack

Get MYKEY Account Information

Get MYKEY Account Information

window.MyKey.Browser.getAccountInfo

Params

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.getClientConfig

Return

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) => Promise

Params

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) => Promise

Params

Param

Type

Description

message

string

unsigned message

Return

Return format: Promise
result: {
	"errorCode": 0,
	"errorMsg": "",
	"data": {
		"signature": ""
	}
}

Get Transaction Progress

window.MyKey.Browser.getTransactionProgress

Params

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.showLoading

Hidden loading animation

hidden loading animation

window.MyKey.Browser.hiddenLoading

serialize specified function call

serialize specified function call

window.MyKey.Browser.encodeFunctionCall(abi, method, param) => Promise

Return

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