├── chinese ├── README.md ├── mykey_jsbridge.md ├── mykey_development_toolkit.md ├── mykey_simplewallet.md ├── mykey_ios_sdk.md └── mykey_android_sdk.md ├── english ├── README.md ├── mykey_jsbridge_en.md ├── mykey_development_toolkit_en.md ├── mykey_simplewallet_en.md ├── mykey-on-eosio.md ├── mykey_ios_sdk_en.md └── mykey_android_sdk_en.md ├── image ├── iOSbitcode.jpg ├── iOSURLTypes.jpg ├── iOSbridging.jpg ├── account_model.png ├── SimpleWalletDAppSign.jpg ├── SimpleWalletWebSign.jpg ├── SimpleWalletDAppContract.jpg ├── SimpleWalletWebContract.jpg └── iOSLSApplicationQueriesSchemes.jpg ├── .gitbook └── assets │ ├── demoschema.png │ ├── info.list.png │ ├── iosbitcode.jpg │ ├── iosbridging.jpg │ ├── iosurltypes.jpg │ ├── account_model.png │ ├── bridingheader.png │ ├── enable-bitcode.png │ ├── iosbitcode (1).jpg │ ├── iosbitcode (2).jpg │ ├── iosbitcode (3).jpg │ ├── iosbridging (1).jpg │ ├── iosbridging (2).jpg │ ├── iosbridging (3).jpg │ ├── iosurltypes (1).jpg │ ├── iosurltypes (2).jpg │ ├── iosurltypes (3).jpg │ ├── account_model (1).png │ ├── mykey_whitepaper_cn.pdf │ ├── mykey_whitepaper_en.pdf │ ├── simplewalletdappsign.jpg │ ├── simplewalletwebsign.jpg │ ├── simplewalletdappcontract.jpg │ ├── simplewalletdappsign (1).jpg │ ├── simplewalletwebcontract.jpg │ ├── simplewalletwebsign (1).jpg │ ├── simplewalletwebcontract (1).jpg │ ├── ioslsapplicationqueriesschemes.jpg │ ├── simplewalletdappcontract (1).jpg │ ├── ioslsapplicationqueriesschemes (1).jpg │ ├── ioslsapplicationqueriesschemes (2).jpg │ └── ioslsapplicationqueriesschemes (3).jpg ├── Whitepaper ├── mykey_whitepaper_cn.pdf ├── mykey_whitepaper_en.pdf └── mykey_whitepaper_kr_draft.pdf ├── SUMMARY.md ├── README.md └── LICENSE /chinese/README.md: -------------------------------------------------------------------------------- 1 | # Chinese 2 | 3 | -------------------------------------------------------------------------------- /english/README.md: -------------------------------------------------------------------------------- 1 | # English 2 | 3 | -------------------------------------------------------------------------------- /image/iOSbitcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/iOSbitcode.jpg -------------------------------------------------------------------------------- /image/iOSURLTypes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/iOSURLTypes.jpg -------------------------------------------------------------------------------- /image/iOSbridging.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/iOSbridging.jpg -------------------------------------------------------------------------------- /image/account_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/account_model.png -------------------------------------------------------------------------------- /.gitbook/assets/demoschema.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/demoschema.png -------------------------------------------------------------------------------- /.gitbook/assets/info.list.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/info.list.png -------------------------------------------------------------------------------- /.gitbook/assets/iosbitcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbitcode.jpg -------------------------------------------------------------------------------- /image/SimpleWalletDAppSign.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/SimpleWalletDAppSign.jpg -------------------------------------------------------------------------------- /image/SimpleWalletWebSign.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/SimpleWalletWebSign.jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosbridging.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbridging.jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosurltypes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosurltypes.jpg -------------------------------------------------------------------------------- /.gitbook/assets/account_model.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/account_model.png -------------------------------------------------------------------------------- /.gitbook/assets/bridingheader.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/bridingheader.png -------------------------------------------------------------------------------- /.gitbook/assets/enable-bitcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/enable-bitcode.png -------------------------------------------------------------------------------- /.gitbook/assets/iosbitcode (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbitcode (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosbitcode (2).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbitcode (2).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosbitcode (3).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbitcode (3).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosbridging (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbridging (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosbridging (2).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbridging (2).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosbridging (3).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosbridging (3).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosurltypes (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosurltypes (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosurltypes (2).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosurltypes (2).jpg -------------------------------------------------------------------------------- /.gitbook/assets/iosurltypes (3).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/iosurltypes (3).jpg -------------------------------------------------------------------------------- /Whitepaper/mykey_whitepaper_cn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/Whitepaper/mykey_whitepaper_cn.pdf -------------------------------------------------------------------------------- /Whitepaper/mykey_whitepaper_en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/Whitepaper/mykey_whitepaper_en.pdf -------------------------------------------------------------------------------- /image/SimpleWalletDAppContract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/SimpleWalletDAppContract.jpg -------------------------------------------------------------------------------- /image/SimpleWalletWebContract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/SimpleWalletWebContract.jpg -------------------------------------------------------------------------------- /.gitbook/assets/account_model (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/account_model (1).png -------------------------------------------------------------------------------- /.gitbook/assets/mykey_whitepaper_cn.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/mykey_whitepaper_cn.pdf -------------------------------------------------------------------------------- /.gitbook/assets/mykey_whitepaper_en.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/mykey_whitepaper_en.pdf -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletdappsign.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletdappsign.jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletwebsign.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletwebsign.jpg -------------------------------------------------------------------------------- /Whitepaper/mykey_whitepaper_kr_draft.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/Whitepaper/mykey_whitepaper_kr_draft.pdf -------------------------------------------------------------------------------- /image/iOSLSApplicationQueriesSchemes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/image/iOSLSApplicationQueriesSchemes.jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletdappcontract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletdappcontract.jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletdappsign (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletdappsign (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletwebcontract.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletwebcontract.jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletwebsign (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletwebsign (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletwebcontract (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletwebcontract (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/ioslsapplicationqueriesschemes.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/ioslsapplicationqueriesschemes.jpg -------------------------------------------------------------------------------- /.gitbook/assets/simplewalletdappcontract (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/simplewalletdappcontract (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/ioslsapplicationqueriesschemes (1).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/ioslsapplicationqueriesschemes (1).jpg -------------------------------------------------------------------------------- /.gitbook/assets/ioslsapplicationqueriesschemes (2).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/ioslsapplicationqueriesschemes (2).jpg -------------------------------------------------------------------------------- /.gitbook/assets/ioslsapplicationqueriesschemes (3).jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mykeylab/Documentation/HEAD/.gitbook/assets/ioslsapplicationqueriesschemes (3).jpg -------------------------------------------------------------------------------- /SUMMARY.md: -------------------------------------------------------------------------------- 1 | # Table of contents 2 | 3 | * [Documentation](README.md) 4 | * [Chinese](chinese/README.md) 5 | * [MYKEY-JSBridge](chinese/mykey_jsbridge.md) 6 | * [MYKEY Android SDK](chinese/mykey_android_sdk.md) 7 | * [MYKEY iOS SDK](chinese/mykey_ios_sdk.md) 8 | * [兼容SimpleWallet协议](chinese/mykey_simplewallet.md) 9 | * [MYKEY Development Toolkit](chinese/mykey_development_toolkit.md) 10 | * [English](english/README.md) 11 | * [MYKEY on EOSIO](english/mykey-on-eosio.md) 12 | * [MYKEY Development Toolkit](english/mykey_development_toolkit_en.md) 13 | * [SimpleWallet Protocol Compatible](english/mykey_simplewallet_en.md) 14 | * [MYKEY iOS SDK](english/mykey_ios_sdk_en.md) 15 | * [MYKEY-JSBridge-EN](english/mykey_jsbridge_en.md) 16 | * [MYKEY Android SDK](english/mykey_android_sdk_en.md) 17 | 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Documentation 2 | 3 | ## English Catalog 4 | 5 | * [Whitepaper](https://github.com/mykeylab/Documentation/tree/0b4c091fe4c023a4f0140f095271ef50af4c5fa6/Whitepaper/mykey_whitepaper_en.pdf) 6 | * [MYKEY on EOSIO](english/mykey-on-eosio.md) 7 | * [MYKEY Development Tool](english/mykey_development_toolkit_en.md) 8 | * [MYKEY Client SDK](https://github.com/mykeylab/MYKEY-Client-SDK) 9 | * [Andriod](english/mykey_android_sdk_en.md) 10 | * [iOS](english/mykey_ios_sdk_en.md) 11 | * [MYKEY JSBridge](english/mykey_jsbridge_en.md) 12 | * [MYKEY SimpleWallet](english/mykey_simplewallet_en.md) 13 | 14 | ## 中文目录 15 | 16 | * [白皮书](https://github.com/mykeylab/Documentation/tree/0b4c091fe4c023a4f0140f095271ef50af4c5fa6/Whitepaper/mykey_whitepaper_cn.pdf) 17 | * [MYKEY on EOSIO](https://github.com/mykeylab/Documentation/tree/0b4c091fe4c023a4f0140f095271ef50af4c5fa6/Chinese/MYKEY%20on%20EOSIO.md) 18 | * [MYKEY Development Tool](chinese/mykey_development_toolkit.md) 19 | * [MYKEY Client SDK](https://github.com/mykeylab/MYKEY-Client-SDK) 20 | * [Andriod](chinese/mykey_android_sdk.md) 21 | * [iOS](chinese/mykey_ios_sdk.md) 22 | * [MYKEY JSBridge](chinese/mykey_jsbridge.md) 23 | * [MYKEY SimpleWallet](chinese/mykey_simplewallet.md) 24 | 25 | -------------------------------------------------------------------------------- /chinese/mykey_jsbridge.md: -------------------------------------------------------------------------------- 1 | # MYKEY-JSBridge 2 | 3 | JSBridge 为MYKEY应用中心内嵌的浏览器环境中默认支持的JS注入库,其支持Scatter协议,开发者可以使用[Scatter文档](https://get-scatter.com/docs/api-reference)进行H5 DApp的开发。在支持以太坊后也会支持web3协议。 4 | 5 | **特别注意:** [MYKEY的账号体系](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#mykey-account-structure)与其他的EOS账号有所差异,需要在服务端验签时使用Reserved公钥进行验签,详细请查阅[文档](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 6 | 7 | 此外为了方便控制MYKEY应用中心浏览器的一些额外属性,如全屏,签名弹框方向,关闭应用等 8 | 9 | ## 开启全屏 10 | 11 | 进入全屏模式,应用可以通过isLandscape指定签名弹出框的方向 12 | 13 | ```text 14 | // isLandscape: 全屏模式中MYKEY签名弹出框的方向, ture为横屏,false为竖屏 15 | window.MyKey.Browser.openFullScreen(isLandscape) 16 | ``` 17 | 18 | ## 退出全屏 19 | 20 | 非全屏模式下,MYKEY签名弹出框永远为竖屏状态 21 | 22 | ```text 23 | window.MyKey.Browser.closeFullScreen() 24 | ``` 25 | 26 | ## 退出 27 | 28 | 退出DApp,销毁当前DApp窗口 29 | 30 | ```text 31 | window.MyKey.Browser.closeWindow() 32 | ``` 33 | 34 | ## 禁用返回 35 | 36 | 禁用系统原生返回按钮 37 | 38 | ```text 39 | window.MyKey.Browser.forbidPhysicalBack() 40 | ``` 41 | 42 | ## 允许返回 43 | 44 | 允许系统原生返回按钮 45 | 46 | ```text 47 | window.MyKey.Browser.allowPhysicalBack() 48 | ``` 49 | 50 | -------------------------------------------------------------------------------- /chinese/mykey_development_toolkit.md: -------------------------------------------------------------------------------- 1 | # MYKEY Development Toolkit 2 | 3 | ## 简介 4 | 5 | MYKEY Development Toolkit\(MDK\)是方便开发者基于MYKEY账户体系开发应用的工具包。其包含MYKEY Client SDK,JSBridge Lib,Deeplink以及SimpleWallet协议扩展。该套开发者工具包可以帮助应用唤起MYKEY进行登录、转账、合约调用、签名等多种链上操作。该工具包暂只支持EOS链,并会随着MYKEY对多链的支持进行拓展。 6 | 7 | ## MYKEY Client SDK 8 | 9 | MYKEY Client SDK 由 iOS SDK, Android SDK和MYKEY Core组成。 10 | 11 | MYKEY Core通过GO语言实现,封装了MYKEY与MYKEY服务端和区块链交互的逻辑,目前以二进制包形式提供给Android以JNI方式,iOS以静态库方式调用,暂不对外开源。 12 | 13 | Android SDK和iOS SDK可以帮助简化APP开发者使用MYKEY账号进行登录、转账、合约、签名操作。同时也封装了使用[eos-stake-token合约](https://github.com/mykeylab/eos-stake-token)发行的通证的额外合约操作,其中也包含了一些示例代码实现。 14 | 15 | ### Android SDK 16 | 17 | [文档](mykey_android_sdk.md) 18 | 19 | ### iOS SDK 20 | 21 | [文档](mykey_ios_sdk.md) 22 | 23 | ## JSBridge Lib 24 | 25 | JSBridge 为MYKEY应用中心内嵌的浏览器环境中默认支持的JS注入库,其支持Scatter协议,开发者可以使用[Scatter文档](https://get-scatter.com/docs/api-reference)进行H5 DApp的开发。在支持以太坊后也会支持web3协议。 26 | 27 | [JSBridge Documentation](mykey_jsbridge.md) 28 | 29 | ## SimpleWallet协议 30 | 31 | MYKEY遵循SimpleWallet协议实现,详细请见以下文档: 32 | 33 | [SimpleWallet Documentation](mykey_simplewallet.md) 34 | 35 | ## DeepLink协议 36 | 37 | ### 打开MYKEY 38 | 39 | mykey://mykey.org/ 40 | 41 | ### dapp跳转MYKEY并直接打开 42 | 43 | mykey://mykey.org/dapp?url=%encodeURIComponent\(Dapp\_URL\)% 44 | 45 | ## ISSUE报告 46 | 47 | 请在github中的issue板块提交ticket 48 | 49 | ## FAQ 50 | 51 | -------------------------------------------------------------------------------- /english/mykey_jsbridge_en.md: -------------------------------------------------------------------------------- 1 | # MYKEY-JSBridge-EN 2 | 3 | JSBridge is injected javascript code in MYKEY dapp browser enviroment by default, it support Scatter protocol, developers can develop H5 dapp follow [Scatter Document](https://get-scatter.com/docs/api-reference), it will also support web3js protocol when MYKEY support ETH. 4 | 5 | **Special Notice:** [MYKEY account structure](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#mykey-account-structure) is different with other EOS account, if dapp verify signature in their server side, should use the public key of Reserved, more details see this [Document](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 6 | 7 | For ease of use, it provided a few extra methods, e.g. fullscreen, rotation of the sign box, close window and so on 8 | 9 | ## Enter fullscreen mode 10 | 11 | Enter fullscreen mode, dapp can adjust the rotation of the sign box according the value of isLandscape 12 | 13 | ```text 14 | // isLandscape: Rotation of the sign box , ture as horizontal,false as vertical. 15 | window.MyKey.Browser.openFullScreen(isLandscape) 16 | ``` 17 | 18 | ## Exit fullscreen mode 19 | 20 | In non-fullscreen mode, the rotation of the sign box always in vertical screen mode. 21 | 22 | ```text 23 | window.MyKey.Browser.closeFullScreen() 24 | ``` 25 | 26 | ## Quit 27 | 28 | Quit dapp, destory the current window 29 | 30 | ```text 31 | window.MyKey.Browser.closeWindow() 32 | ``` 33 | 34 | ## Forbid Physical Back \(Only in Android\) 35 | 36 | Fobid native physical back button in Android 37 | 38 | ```text 39 | window.MyKey.Browser.forbidPhysicalBack() 40 | ``` 41 | 42 | ## Allow Physical Back \(Only in Android\) 43 | 44 | Allow native physical back button in Android 45 | 46 | ```text 47 | window.MyKey.Browser.allowPhysicalBack() 48 | ``` 49 | 50 | -------------------------------------------------------------------------------- /english/mykey_development_toolkit_en.md: -------------------------------------------------------------------------------- 1 | # MYKEY Development Toolkit 2 | 3 | ## Introduction 4 | 5 | MYKEY Development Toolkit, aka MDK, a toolkit for developers to develop applications based on the MYKEY account system. It contains MYKEY Client SDK, JSBridge Lib and SimpleWallet protocol extension. This suite of development toolkit can help applications wake up MYKEY to login, transfer, contracts invoke, sign and other on-chain operations. This tooklit only support EOS chain by now, and will extend to other public chains with the roadmap of MYKEY for multi-chain. 6 | 7 | ## MYKEY Client SDK 8 | 9 | The MYKEY Client SDK consists of the iOS SDK, Android SDK and MYKEY Core. 10 | 11 | MYKEY Core is implemented by GO language, and encapsulates the interaction logic of MYKEY Client App to MYKEY server and blockchain. It is provided to Android in the form of binary package via JNI mode. iOS implemented via static library, and it wasn't open sourced by now. 12 | 13 | The Android SDK and iOS SDK can help APP developers to simplify implement to use MYKEY accounts to log in, transfer, contract, and sign up. The SDKs also include extra contract operations for the token issued by \[eos-stake-token contract\] \([https://github.com/mykeylab/eos-stake-token](https://github.com/mykeylab/eos-stake-token)\), which also includes some sample code. 14 | 15 | ### Android SDK 16 | 17 | [docuemnt](mykey_android_sdk_en.md) 18 | 19 | ### iOS SDK 20 | 21 | [document](mykey_ios_sdk_en.md) 22 | 23 | ## JSBridge Lib 24 | 25 | JSBridge is injected javascript code in MYKEY dapp browser enviroment by default, it support Scatter protocol, developers can develop H5 dapp follow [Scatter Document](https://get-scatter.com/docs/api-reference), it will also support web3js protocol when MYKEY support ETH. 26 | 27 | [JSBridge Documentation](mykey_jsbridge_en.md) 28 | 29 | ## SimpleWallet protocol 30 | 31 | MYKEY follows the SimpleWallet protocol implementation. See the following document for details: 32 | 33 | [SimpleWallet Documentation](mykey_simplewallet_en.md) 34 | 35 | ## DeepLink Protocol 36 | 37 | ### Open MYKEY Application 38 | 39 | mykey://mykey.org/ 40 | 41 | ### Open MYKEY and redirect to specific dapp 42 | 43 | mykey://mykey.org/dapp?url=%encodeURIComponent\(Dapp\_URL\)% 44 | 45 | ## Issue Report 46 | 47 | Please submit issue in github 48 | 49 | ## FAQ 50 | 51 | -------------------------------------------------------------------------------- /chinese/mykey_simplewallet.md: -------------------------------------------------------------------------------- 1 | # 兼容SimpleWallet协议 2 | 3 | ## 使用SimpleWallet跳转MYKEY代码示例 4 | 5 | **特别注意:** Android端SimpleWallet跳转MYKEY时请使用如下代码(设置MYKEY的包名) 6 | 7 | ```text 8 | try { 9 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 10 | intent.setPackage("com.mykey.id"); 11 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 12 | context.startActivity(intent); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | ``` 17 | 18 | ## 登录和支付 19 | 20 | MYKEY遵循SimpleWallet协议实现,详细请见以下文档: 21 | 22 | [https://github.com/southex/SimpleWallet/blob/master/README\_en.md](https://github.com/southex/SimpleWallet/blob/master/README_en.md) 23 | 24 | 除了支持SimpleWallet规范的**登录**和**支付**,MYKEY还额外增强支持了**合约**和**签名**的调用。 25 | 26 | **特别注意:** [MYKEY的账号体系](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#mykey-account-structure)与其他的EOS账号有所差异,需要在服务端验签时使用Reserved公钥进行验签,详细请查阅[文档](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 27 | 28 | ## 合约 29 | 30 | ### Web扫码调用合约时序图 31 | 32 | ![](../.gitbook/assets/simplewalletwebcontract.jpg) 33 | 34 | ### 移动端App调用合约时序图 35 | 36 | ![](../.gitbook/assets/simplewalletdappcontract%20%281%29.jpg) 37 | 38 | 请传递给MYKEY如下的数据,数据格式为json: 39 | 40 | ```text 41 | // 合约调用数据格式 42 | { 43 | protocol string // 协议名,本协议默认 SimpleWallet 44 | version string // 协议版本信息,如1.0 45 | action string // 操作类型,为 transaction 46 | dappName string // DApp应用名 47 | dappIcon string // DApp应用图标 48 | desc string // MYKEY显示给用户合约调用语义描述 49 | callback string // MYKEY回调DApp的深度链接,e.g. custom://custom.com/contract 50 | notifyUrl string // 合约调用成功通知DAppServer的回调URL接口 51 | ContractRequest [ //合约操作数组,包含转账与非转账合约操作 52 | { //非转账 53 | account string // 合约名 54 | name string // 合约方法 55 | info string // MYKEY显示给用户的语义化描述 56 | data object // 根据合约abi定义所传的参数对象 e.g. {key1: value1, key2: value2 } 57 | }, 58 | { //转账 59 | account string // 合约名 60 | name string // 合约方法 61 | info string // MYKEY显示给用户的语义化描述 62 | TransferDataRequest { 63 | from string // 转账From 64 | to string // 转账To 65 | quantity string // 转账金额和单位,e.g. "1.0000 EOS" 66 | memo string // 链上备注 67 | } 68 | } 69 | ] 70 | expired number // 仅Web二维码模式可用,过期时间,unix时间戳 71 | } 72 | ``` 73 | 74 | ## 签名 75 | 76 | ### Web扫码调用签名时序图 77 | 78 | ![](../.gitbook/assets/simplewalletwebsign%20%281%29.jpg) 79 | 80 | ### 移动端App调用签名时序图 81 | 82 | ![](../.gitbook/assets/simplewalletdappsign%20%281%29.jpg) 83 | 84 | 请传递给MYKEY如下的数据,数据格式为json: 85 | 86 | ```text 87 | // 签名调用数据格式 88 | { 89 | protocol string // 协议名,本协议默认 SimpleWallet 90 | version string // 协议版本信息,如1.0 91 | action string // 操作类型,为 sign 92 | dappName string // DApp应用名 93 | dappIcon string // DApp应用图标 94 | desc string // MYKEY显示给用户签名调用语义描述 95 | message string // 需要签名的内容 96 | callback string // MYKEY回调DApp的深度链接,e.g. custom://custom.com/contract 97 | notifyUrl string // 签名成功通知DAppServer的回调URL接口 98 | expired number // 仅Web二维码模式可用,过期时间,unix时间戳 99 | } 100 | ``` 101 | 102 | -------------------------------------------------------------------------------- /english/mykey_simplewallet_en.md: -------------------------------------------------------------------------------- 1 | # SimpleWallet Protocol Compatible 2 | 3 | ## Sample code for redirect to MYKEY 4 | 5 | **Reminder:** In Android client, for avoid conflict with other wallets, developer can use following code to rediect to MYKEY precisely through set the MYKEY packge name: com.mykye.id 6 | 7 | ```text 8 | try { 9 | Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 10 | intent.setPackage("com.mykey.id"); 11 | intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 12 | context.startActivity(intent); 13 | } catch (Exception e) { 14 | e.printStackTrace(); 15 | } 16 | ``` 17 | 18 | ## Login and Transfer 19 | 20 | MYKEY follows the SimpleWallet protocol implementation. See the following document for details: 21 | 22 | [https://github.com/southex/SimpleWallet/blob/master/README\_en.md](https://github.com/southex/SimpleWallet/blob/master/README_en.md) 23 | 24 | Beside support **login** and **transfer** of SimpleWallet specification,MYKEY also additionally supports **contract** and **signature** method. 25 | 26 | **Special Notice:** [MYKEY account structure](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#mykey-account-structure) is different with other EOS account, if dapp verify signature in their server side, should use the public key of Reserved, more details see this [Document](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 27 | 28 | ## Contract 29 | 30 | ### Sequence diagram for Web QR code scan 31 | 32 | ![](../.gitbook/assets/simplewalletwebcontract.jpg) 33 | 34 | ### Sequence diagram for Mobile applcaiton wake up 35 | 36 | ![](../.gitbook/assets/simplewalletdappcontract%20%281%29.jpg) 37 | 38 | Please pass the data to MYKEY as follows, the data format is json: 39 | 40 | ```text 41 | // Contract call data format 42 | 43 | { 44 | protocol string // protocol name,use "SimpleWallet" by default 45 | version string // protocol version, e.g. "1.0" 46 | action string // action type, use "transaction" 47 | dappName string // DApp name 48 | dappIcon string // DApp icon url 49 | desc string // Semantic description of MYKEY display to the user contract call 50 | callback string // Deeplink MYKEY callback to DApp, e.g. custom://custom.com/contract 51 | notifyUrl string // The callback URL endpoint of DAppServer for receive success notification from MYKEY 52 | ContractRequest [ // Arrary of contact actions, include transfer and non-transfer actions 53 | { // non-transfer 54 | account string // contract code name 55 | name string // contract action name 56 | info string // Semantic description of MYKEY display to the user about this action 57 | data object // The parameter object passed according to the contract abi definition e.g. {key1: value1, key2: value2 } 58 | }, 59 | { // transfer 60 | account string // contract code name 61 | name string // contract action name 62 | info string // Semantic description of MYKEY display to the user about this action 63 | TransferDataRequest { 64 | from string // From 65 | to string // To 66 | quantity string // Amount and Symbol,e.g. "1.0000 EOS" 67 | memo string // Memo 68 | } 69 | } 70 | ] 71 | expired number // 仅Web二维码模式可用,过期时间,unix时间戳 72 | } 73 | ``` 74 | 75 | ## Sign 76 | 77 | ### Sequence diagram for Web QR code scan 78 | 79 | ![](../.gitbook/assets/simplewalletwebsign%20%281%29.jpg) 80 | 81 | ### Sequence diagram for Mobile applcaiton wake up 82 | 83 | ![](../.gitbook/assets/simplewalletdappsign%20%281%29.jpg) 84 | 85 | Please pass the data to MYKEY as follows, the data format is json: 86 | 87 | ```text 88 | // Sign call data format 89 | { 90 | protocol string // protocol name,use "SimpleWallet" by default 91 | version string // protocol version, e.g. "1.0" 92 | action string // action type, use "sign" 93 | dappName string // DApp name 94 | dappIcon string // DApp icon url 95 | desc string // Semantic description of MYKEY display to the user contract call 96 | message string // Unsigned messages 97 | callback string // Deeplink MYKEY callback to DApp, e.g. custom://custom.com/contract 98 | notifyUrl string // The callback URL endpoint of DAppServer for receive success notification from MYKEY 99 | expired number // Only in web QR code mode, expire date,unix timestamp 100 | } 101 | ``` 102 | 103 | -------------------------------------------------------------------------------- /english/mykey-on-eosio.md: -------------------------------------------------------------------------------- 1 | # MYKEY on EOSIO 2 | 3 | MYKEY is a Self-sovereign Identity System. The underlying protocol is called KEY ID. 4 | 5 | The purpose of this document is to explain the differences between MYKEY account and traditional EOS account. 6 | 7 | Meanwhile, document will demonstrate the simple way to make your code compatible with MYKEY App. 8 | 9 | ## What are the differences on MYKEY? 10 | 11 | To improve user experiences and lower the threshold of EOS usage, MYKEY designed to resolve the problem of private key management and resource consumption management based on KEY ID protocol. 12 | 13 | More details in [MYKEY Whitepaper](https://github.com/mykeylab/Documentation/tree/536e19a72f78276d2fbf84336bde6bc897d4867a/Whitepaper/mykey_whitepaper_en.pdf) 14 | 15 | MYKEY has re-designed the native EOS account by KEY ID Smart Contracts that split two parts on EOS mainnet. 16 | 17 | * [mykeymanager](https://bloks.io/account/mykeymanager) 18 | * [mykeylogica1](https://bloks.io/account/mykeylogica1) 19 | 20 | In EOS, MYKEY supports features like key recovery, privilege level, free account, free usage, authentication, sub account and so on. For easy understanding, MYKEY tries to hide technical concept for end users. In MYKEY App, user do not have to care about CPU/NET/RAM of their EOS account. 21 | 22 | But at the same time, user's account still stays self-sovereign, authority belongs to users. More details will be disclosed in coming documentation and open-source plan. 23 | 24 | ## MYKEY account structure 25 | 26 | There are two types of key in MYKEY account structure: Admin Key and Operation Key. In SmartContract, Admin Key cannot sign any general transaction except sign transaction to replace Operation Keys with time-lock. 27 | 28 | ![MYKEY account system and private keys authorization structure](../.gitbook/assets/account_model%20%281%29.png) 29 | 30 | The private key of Admin Key generated by mobile device which can be cold-backup through recovery code or hardware wallet during registration. The private keys of Operation Keys generated and secure stored by mobile device. 31 | 32 | The public keys of Admin Key and Operation Keys are used to signup account and stored in SmartContract for further on-chain signature verification. 33 | 34 | With those novel design principle, MYKEY can help dapp build their own native dapp without any explicit sign between dapp and 3rd party wallets. What's more, users can safely manage their asset, vault account, dapp accounts, data by different operation keys which is in one single account, we call it Self-sovereign Identity. 35 | 36 | ## Keys in table `keydata` 37 | 38 | Every keys of MYKEY account will be stored in table `keydata` of contract `mykeymanager`, we can use `ACCOUNT_NAME` as scope to query all keys in MYKEY account. 39 | 40 | Use following account `mykeyhulu521` for example, 41 | 42 | [https://eosq.app/account/mykeymanager/tables?scope=mykeyhulu521&tableName=keydata](https://eosq.app/account/mykeymanager/tables?scope=mykeyhulu521&tableName=keydata) 43 | 44 | MYKEY predefined four keys for every account during sign up. Details shown in the following table 45 | 46 | | Index | Use | 47 | | :---: | :--- | 48 | | 0 | AdminKey: Top privilege, can manage other operation keys | 49 | | 1 | OperationKey 1/Asset key: only use for transfer assets | 50 | | 2 | OperationKey 2/Adding key: For creating more new operation keys | 51 | | 3 | OperationKey 3/Reserved key: For other actions without specific operation keys | 52 | 53 | ## Integrate EOS dapps with MYKEY 54 | 55 | Because MYKEY does some customization on EOS account structure, there're some good tips for dapp developers. 56 | 57 | ### 1. Ignore the CPU and NET monitor 58 | 59 | Because MYKEY take care all resource status for users. Every MYKEY account always stake 0 CPU and 0 NET on EOS chain. So dapps user interface should ignore resource warning for MYKEY account. 60 | 61 | ### 2. For dapps compatible with Scatter 62 | 63 | MYKEY almost compatible with interfaces of Scatter protocol. The only difference from traditional wallet is MYKEY will use one of its 3rd OperationKey/Reserved Key to sign transactions instead of the EOS owner/active key. 64 | 65 | Any actions of original contacts will be wrapped by MYKEY app, then send to [mykeymanager](https://bloks.io/account/mykeymanager) for verify signature and then forward to the target contracts. In most of cases, anything works correctly without any changes in code. 66 | 67 | #### _How to check dapps are running in MYKEY webview_ 68 | 69 | There are two methods to check if dapps are running in MYKEY client. 70 | 71 | 1. Use `navigator.userAgent` to check. MYKEY webview will append `MYKEY/[version]` after the original userAgent. 72 | 73 | ```text 74 | function isMYKEY(){ 75 | return navigator.userAgent.indexOf("MYKEY") > -1; 76 | } 77 | ``` 78 | 79 | 1. Use `scatter.getIdentity` to check if the response data contain `type:'MYKEY'`, 80 | 81 | the return data snippet 82 | 83 | ```text 84 | { 85 | accounts: [{authority: 'active', blockchain: 'eos', name: [ACCOUNT_NAME], type: 'MYKEY'}], 86 | publicKey: [OperationKey 3/Reserved key] 87 | }; 88 | ``` 89 | 90 | #### _If dapp dependents on `getArbitrarySignature` or other server side authentication_ 91 | 92 | For dapps are using method `scatter.getArbitrarySignature` or other method to verify account authority in sever side. The code for verifying signature should be refined for MYKEY account. 93 | 94 | In this case. MYKEY uses the reserved key which index is 3 to sign through `scatter.getArbitrarySignature`. Server side of dapps need use the corresponding public key of reserved key to verify signature, it can be queried by backend code in table `keydata` of contract [`mykeymanager`](https://eosq.app/account/mykeymanager/tables?scope=mykeyhulu521&tableName=keydata) by scope `ACCOUNT_NAME`. 95 | 96 | We already implemented some sample code for reference. Please check it out. 97 | 98 | [https://github.com/mykeylab/mykey-js-sdk/blob/master/src/index.js\#L79-L86](https://github.com/mykeylab/mykey-js-sdk/blob/master/src/index.js#L79-L86) 99 | 100 | ### 3. For native dapps 101 | 102 | MYKEY Development Toolkit, aka MDK, a toolkit for developers to develop applications based on the MYKEY account system. It contains MYKEY Client SDK, JSBridge Lib and SimpleWallet protocol extension. This suite of development toolkit can help applications wake up MYKEY to login, transfer, contracts invoke, sign and other on-chain operations. This tooklit only support EOS chain by now, and will extend to other public chains with the roadmap of MYKEY for multi-chain. 103 | 104 | Native dapps can use [MYKEY Development Tool](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY_DEVELOPMENT_TOOLKIT_EN.md) to use MYKEY to authorize, transfer, contract, sign. I 105 | 106 | ### 4. Application Op Key support\(coming soon\) 107 | 108 | MYKEY support dapps develop their own native application. Dapps can generate one keypair locally in their own application. Then bind the generated public key to MYKEY account via inter-application calls. 109 | 110 | In this model, Dapps can use MYKEY SDKs to sign and push transactions locally and unnecessary to wake up 3rd wallet. By authority leveled design, user can decide how much assets they want to put into sub-account for one specific dapp, the risk of the asset can be controlled easily. 111 | 112 | Details coming soon! 113 | 114 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /chinese/mykey_ios_sdk.md: -------------------------------------------------------------------------------- 1 | # MYKEY iOS SDK 2 | 3 | ## 1.如何集成 4 | 5 | ### 1.1 在以下项目中下载MYKEYWalletLib-iOS.zip,解压后,拖进工程目录; 6 | 7 | [https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/iOS](https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/iOS) 8 | 9 | ### 1.2 在Xcode设置URL scheme: Project->TARGETS->info->URL Types->添加 URL scheme; 10 | 11 | 例如使用demoscheme,详见下图 12 | 13 | ![](../.gitbook/assets/iosurltypes.jpg) 14 | 15 | 这个配置会自动生成MYEKY回掉的深度链接,将会被用于MYKEY SDK的初始化方法中. [详见 initWalletSimple](mykey_ios_sdk.md#initwalletsimple). 16 | 17 | ### 1.3 在info.plist中LSApplicationQueriesSchemes下添加一项,值为mykey; 18 | 19 | ![](../.gitbook/assets/ioslsapplicationqueriesschemes.jpg) 20 | 21 | ### 1.4 Build Settings 下 Enable Bitcode置为false 22 | 23 | ![](../.gitbook/assets/iosbitcode.jpg) 24 | 25 | ### 1.5 备注 26 | 27 | 该库使用swift编写,Objective-C工程需要配置Bridging-Header.h文件,如果工程中没有,可以创建Empty.swift\(一个空的swift文件\),工程会自动生成Bridging-Header.h。 ![](../.gitbook/assets/iosbridging%20%281%29.jpg) 28 | 29 | ## 2.初始化 30 | 31 | ### 2.1 在 AppDelegate.m 中添加头文件 32 | 33 | #### Swift 34 | 35 | ```text 36 | import MYKEYWalletLib 37 | ``` 38 | 39 | #### Objective-C 40 | 41 | ```text 42 | #import 43 | ``` 44 | 45 | ### 执行初始化 46 | 47 | ```text 48 | let initData = InitRequest() 49 | initData.appKey = "xxxx" 50 | initData.dappName = "DappNameA" 51 | initData.dappIcon = "https:.../xx.png" 52 | initData.UUID = "uuidxxxxx" 53 | initData.scheme = "demoscheme" 54 | initData.disableInstall = true 55 | MYKEYWallet.shared.initWallet(initData: initData) 56 | ``` 57 | 58 | 其中,scheme参数[参考1.2中的scheme配置](mykey_ios_sdk.md#12-在xcode设置url-scheme-project-targets-info-url-types-添加-url-scheme) 59 | 60 | ### 2.3 在 application:openURL: 中添加handleUrl方法 61 | 62 | ```text 63 | MYKEYWallet.shared.handleUrl(url: url) 64 | ``` 65 | 66 | ## Class MYKEYWallet 67 | 68 | MYKEY iOS主要的逻辑封装在MYKEYWallet类中, 包含initWallet、initWalletSimple、authorize、transfer、contract、sign. 69 | 70 | ### 方法描述 Method Summary 71 | 72 | | Methods | 73 | | :---: | 74 | | [initWallet](mykey_ios_sdk.md#initwallet) | 75 | | [initWalletSimple](mykey_ios_sdk.md#initwalletsimple) | 76 | | [authorize](mykey_ios_sdk.md#authorize) | 77 | | [transfer](mykey_ios_sdk.md#transfer) | 78 | | [contract](mykey_ios_sdk.md#contract) | 79 | | [sign](mykey_ios_sdk.md#sign) | 80 | 81 | ### initWallet 82 | 83 | 实例化MYKEYWallet类,在主进程中进行SDK初始化,使用此初始化方法,dapp如果存在账户体系,可以与MYKEY进行绑定操作。参数请详见类定义: [InitRequest](mykey_ios_sdk.md#class-initrequest) 84 | 85 | ```text 86 | let initData = InitRequest() 87 | initData.appKey = "xxxx" 88 | initData.dappName = "DappNameA" 89 | initData.dappIcon = "https:.../xx.png" 90 | initData.UUID = UUID 91 | initData.scheme = "demoscheme" 92 | initData.disableInstall = true 93 | MYKEYWallet.shared.initWallet(initData: initData) 94 | ``` 95 | 96 | Scheme参数,[参考1.2 scheme](mykey_ios_sdk.md#12-在xcode设置url-scheme-project-targets-info-url-types-添加-url-scheme) 97 | 98 | ### initWalletSimple 99 | 100 | 实例化MYKEYWallet类,在主进程中进行SDK初始化,底层使用simplewallet协议逻辑,使用此初始化方法,dapp可以没有账户体系,不需要与MYKEY进行绑定操作。参数请详见类定义: [InitSimpleRequest](mykey_ios_sdk.md#class-initsimplerequest) 101 | 102 | ```text 103 | let initSimpleData = InitSimpleRequest() 104 | initSimpleData.dappName = "DappNameA" 105 | initSimpleData.dappIcon = "https:.../xx.png" 106 | initSimpleData.scheme = "demoscheme" 107 | initSimpleData.disableInstall = true 108 | MYKEYWallet.shared.initWalletSimple(initSimpleData: initSimpleData) 109 | ``` 110 | 111 | Scheme参数,[参考1.2 scheme](mykey_ios_sdk.md#12-在xcode设置url-scheme-project-targets-info-url-types-添加-url-scheme) 112 | 113 | ### authorize 114 | 115 | 唤起MYKEY进行认证绑定。参数请详见类定义: [AuthorizeRequest](mykey_ios_sdk.md#class-authorizerequest) 和 [MYKEYResponse](mykey_ios_sdk.md#class-mykeyresponse) 116 | 117 | 为了更强的安全性,可以设置CallBackUrl进行服务端验签 118 | 119 | MYKEY将签名后的数据POST到dapp提供的CallBackUrl,请求dapp服务端验证,dapp服务端需要从合约数据中获取该用户在MYKEY的ReserveKey进行验签,获取方式参考[KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 120 | 121 | dapp提供的CallBackUrl接口参数: 122 | 123 | ```java 124 | { 125 | "protocol": "", // 协议名,使用MYKEY双向绑定方式协议为MYKEY,使用MYKEY轻量级方式协议为MYKEYSimple 126 | "version": "", // 协议版本信息,如1.0 127 | "dapp_key": "", // MYKEY分配的DAPP_KEY,使用MYKEY双向绑定方式时提供,由MYKEY服务端分配,从dapp客户端初始化方法传入 128 | "uuID": "", // 用户id,MYKEY双向绑定方式此字段为dapp客户端初始化时传入的uuid;MYKEY轻量级方式此字段为用户的设备ID; 129 | "sign": "", // eos签名, 签名数据:timestamp + account + uuID + ref 130 | "ref": "", // 来源, mykey 131 | "timestamp": "",// 当前UNIX时间戳, 精确到秒 132 | "account": "" // eos账户名 133 | } 134 | ``` 135 | 136 | 验签方式: 137 | 138 | ```javascript 139 | // generate unsignedMessage 140 | let unsignedData = timestamp + account + uuID + ref 141 | // publicKey: ReserveKey of MYKEY,can be quired from SmartContract https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata 142 | ecc.verify(signature, unsignedData, pubkey) === true 143 | ``` 144 | 145 | dapp提供的CallBackUrl接口返回值: 146 | 147 | ```java 148 | { 149 | "code": 0, // 错误符,等于0是成功,大于0说明请求失败,dapp返回具体的错误码 150 | "message": "" // 返回的提示信息 151 | } 152 | ``` 153 | 154 | 调用例子: 155 | 156 | ```text 157 | let authorizeRequest = AuthorizeRequest() 158 | authorizeRequest.userName = "uchihamadara" 159 | authorizeRequest.info = "Test information" 160 | // param:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 161 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 162 | authorizeRequest.callbackUrl = "https://dappserver.xxx.url" 163 | 164 | MYKEYWallet.shared.authorize(authorizeRequest: authorizeRequest, response: MYKEYResponse.init(success: { (response) in 165 | self.view.makeToast("success") 166 | }, failure: { (errorValue) in 167 | self.view.makeToast("failure") 168 | }, cancelled: { 169 | self.view.makeToast("cancelled") 170 | })) 171 | ``` 172 | 173 | ### transfer 174 | 175 | 唤起MYKEY进行转账。参数请详见类定义: [TransferRequest](mykey_ios_sdk.md#class-transferrequest) 和 [MYKEYResponse](mykey_ios_sdk.md#class-mykeyresponse) 176 | 177 | ```text 178 | let transferData = TransferData() 179 | transferData.from = "mykeyhulu525" 180 | transferData.to = "madaraxliang" 181 | transferData.quantity = "1.31 EOS" 182 | transferData.memo = "transfer-memo" 183 | 184 | let transferActionData = TransferAction() 185 | transferActionData.account = "eosio.token" 186 | transferActionData.name = WalletActionConstants.TRANSFER.rawValue 187 | transferActionData.info = "contract-transfer-info" 188 | transferActionData.data = transferData 189 | 190 | let contractActionData = ContractAction() 191 | contractActionData.account = "eosio" 192 | contractActionData.name = "buyram" 193 | contractActionData.info = "contract-contract-info" 194 | contractActionData.data = ["payer":"mykeyhulu123","receiver":"mykeyhulu111","quant":"1.01 EOS"] 195 | 196 | let contractRequest = ContractRequest() 197 | contractRequest.info = "Perform the mortgage REX operation" 198 | contractRequest.orderId = "BH19004" 199 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 200 | contractRequest.callbackUrl = "https://dappserver.xxx.url" 201 | contractRequest.actions = [transferActionData,contractActionData] 202 | 203 | MYKEYWallet.shared.contract(contractRequest: contractRequest, response: MYKEYResponse.init(success: { (response) in 204 | self.view.makeToast("success") 205 | }, failure: { (errorValue) in 206 | self.view.makeToast("failure") 207 | }, cancelled: { 208 | self.view.makeToast("cancelled") 209 | })) 210 | ``` 211 | 212 | ### contract 213 | 214 | 唤起MYKEY进行合约调用, 支持多Action组合调用, 支持ContractAction和TransferAction两种形式的action类型。 参数请详见类定义: [ContractRequest](mykey_ios_sdk.md#class-contractrequest), [ContractAction](mykey_ios_sdk.md#class-contractaction) , [TransferAction](mykey_ios_sdk.md#class-transferaction) 和 [MYKEYResponse](mykey_ios_sdk.md#class-mykeyresponse). 215 | 216 | ```text 217 | let transferData = TransferData() 218 | transferData.from = "mykeyhulu525" 219 | transferData.to = "madaraxliang" 220 | transferData.quantity = "1.31 EOS" 221 | transferData.memo = "transfer-memo" 222 | 223 | let transferActionData = TransferAction() 224 | transferActionData.account = "eosio.token" 225 | transferActionData.name = WalletActionConstants.TRANSFER.rawValue 226 | transferActionData.info = "contract-transfer-info" 227 | transferActionData.data = transferData 228 | 229 | let contractActionData = ContractAction() 230 | contractActionData.account = "eosio" 231 | contractActionData.name = "buyram" 232 | contractActionData.info = "contract-contract-info" 233 | contractActionData.data = ["payer":"mykeyhulu123","receiver":"mykeyhulu111","quant":"1.01 EOS"] 234 | 235 | let contractRequest = ContractRequest() 236 | contractRequest.info = "Perform the mortgage REX operation" 237 | contractRequest.orderId = "BH19004" 238 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 239 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 240 | contractRequest.callbackUrl = "https://dappserver.xxx.url" 241 | contractRequest.actions = [transferActionData,contractActionData] 242 | 243 | MYKEYWallet.shared.contract(contractRequest: contractRequest, response: MYKEYResponse.init(success: { (response) in 244 | self.presentDataView(data: response) 245 | self.view.makeToast("success") 246 | }, failure: { (errorValue) in 247 | self.presentDataView(data: errorValue) 248 | self.view.makeToast("failure") 249 | }, cancelled: { 250 | self.view.makeToast("cancelled") 251 | })) 252 | ``` 253 | 254 | ### sign 255 | 256 | 唤起MYKEY进行Sign签名操作。参数请详见类定义: [SignRequest](mykey_ios_sdk.md#class-signrequest) 257 | 258 | dapp服务端或者客户端需要从合约数据中获取该用户在MYKEY的ReserveKey进行验签,获取方式参考[KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 259 | 260 | ```text 261 | let signRequest = SignRequest() 262 | signRequest.message = "Messages that need to be signed, [it could be random which come from dapp server]" 263 | // DApp CallbackUrl 264 | // param:{"protocol": "", "version": "", "message": "", "sign": "", "ref": "", "account": ""} 265 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 266 | signRequest.callbackUrl = "https://dappserver.xxx.url" 267 | 268 | MYKEYWallet.shared.sign(signRequest: signRequest, response: MYKEYResponse.init(success: { (response) in 269 | self.view.makeToast("success") 270 | }, failure: { (errorValue) in 271 | self.view.makeToast("failure") 272 | }, cancelled: { 273 | self.view.makeToast("cancelled") 274 | })) 275 | ``` 276 | 277 | ## 其他类定义 278 | 279 | ### Class InitRequest 280 | 281 | | properties | Type | Description | 282 | | :--- | :---: | :--- | 283 | | appKey | String | 为每一个dapp指定的唯一key | 284 | | UUID | UUID | dapp为该用户提供的唯一ID,建议使用uuid | 285 | | dappName | String | dapp的名称 | 286 | | dappIcon | String | dapp的logo, 建议不低于144x144px | 287 | | disableInstall | boolean | 是否禁用MYKEY未安装时显示默认引导页面 | 288 | | scheme | String | MYKEY完成授权操作后返回Dapp的跳转链接,[参考scheme定义 in 1.2](mykey_ios_sdk.md#12-在xcode设置url-scheme-project-targets-info-url-types-添加-url-scheme), e.g. demoscheme | 289 | | mykeyServer | String | MYKEY服务端环境Endpoint | 290 | 291 | ### Class InitSimpleRequest 292 | 293 | | properties | Type | Description | 294 | | :--- | :---: | :--- | 295 | | dappName | String | dapp的名称 | 296 | | dappIcon | String | dapp的logo, 建议不低于144x144px | 297 | | disableInstall | boolean | 是否禁用MYKEY未安装时显示默认引导页面 | 298 | | scheme | String | MYKEY完成授权操作后返回Dapp的跳转链接,[参考scheme定义 in 1.2](mykey_ios_sdk.md#12-在xcode设置url-scheme-project-targets-info-url-types-添加-url-scheme), e.g. demoscheme | 299 | 300 | ### Class AuthorizeRequest 301 | 302 | | properties | Type | Description | 303 | | :--- | :---: | :--- | 304 | | userName | String | 自定义用户名 | 305 | | callBackUrl | String | dapp server的回调url,MYKEY绑定成功会先回调dapp server,然后再唤醒移动端 | 306 | | info | String | 备注信息,用于绑定认证页面的语义化描述 | 307 | 308 | ### Class TransferRequest 309 | 310 | | properties | Type | Description | 311 | | :--- | :---: | :--- | 312 | | from | String | 转账账户 | 313 | | to | String | 接受账户 | 314 | | amount | String | 转账数量 | 315 | | symbol | String | 币种Symbol, e.g. "EOS" | 316 | | contractName | String | 合约名称, e.g. "eosio.token" | 317 | | decimal | String | 币种对应的小数位数 | 318 | | memo | String | 链上的MEMO备注 | 319 | | info | String | 备注信息,用于语义化该笔转账交易 | 320 | | orderId | String | 订单ID,dapp提供的订单ID,可为空 e.g. "20190606001" | 321 | | callbackUrl | String | dapp server的回调url,MYKEY转账成功会先回调dapp server,然后再唤醒移动端 | 322 | 323 | ### Class ContractRequest 324 | 325 | | properties | Type | Description | 326 | | :--- | :---: | :--- | 327 | | orderId | String | dapp 提供的订单ID, 可为空 | 328 | | info | String | 备注信息,用于语义化该笔操作 | 329 | | callbackUrl | String | dapp server的回调url,MYKEY合约调用成功会先回调dapp server,然后再唤醒移动端 | 330 | | actions: \[BaseAction\] | [ContractAction](mykey_ios_sdk.md#class-contractaction) 或者 [TransferAction](mykey_ios_sdk.md#class-transferaction) | 合约操作action的列表 | 331 | 332 | ### Class ContractAction 333 | 334 | | properties | Type | Description | 335 | | :--- | :---: | :--- | 336 | | account | String | 合约名 | 337 | | name | String | 合约方法 | 338 | | info | String | 备注信息,用于语义化该笔操作 | 339 | | data | Any | 根据合约abi定义所传的参数,类型需能通过JSONSerialization.isValidJSONObject\(\_ obj: Any\)验证, e.g. {key1: value1, key2: value2 } | 340 | 341 | ### Class TransferAction 342 | 343 | | properties | Type | Description | 344 | | :--- | :---: | :--- | 345 | | account | String | 合约名 | 346 | | name | String | 合约方法,填写"transfer" | 347 | | info | String | 备注信息,用于语义化该笔操作 | 348 | | data | [TransferData](mykey_ios_sdk.md#class-transferdata) | 转账信息对象 | 349 | 350 | ### Class TransferData 351 | 352 | | properties | Type | Description | 353 | | :--- | :---: | :--- | 354 | | from | String | 转账支出账号 | 355 | | to | String | 转账接收账号 | 356 | | quantity | String | 转账金额与单位 | 357 | | memo | String | 链上备注信息 | 358 | 359 | ### Class SignRequest 360 | 361 | | properties | Type | Description | 362 | | :--- | :---: | :--- | 363 | | message | String | 需要签名的数据 | 364 | | callbackUrl | String | dapp server的回调url,MYKEY签名成功会先回调dapp server,然后再唤醒移动端 | 365 | 366 | ### Class MYKEYResponse 367 | 368 | | properties | Description | 369 | | :--- | :--- | 370 | | success | 成功的回调 | 371 | | failure | 失败的回调, [errorCode list](mykey_ios_sdk.md#error-code) | 372 | | cancelled | 取消交易的回调 | 373 | 374 | ### Class MYKEYApiResponse 375 | 376 | | properties | Description | 377 | | :--- | :--- | 378 | | success | 成功的回调 | 379 | | failure | 失败的回调 | 380 | 381 | ## Error Code 382 | 383 | 0-2为SimpleWallet定义字段 384 | 385 | 10001-X为MYKEYSdk定义字段 386 | 387 | | code | Description | 388 | | :--- | :--- | 389 | | 0 | 用户主动取消操作 | 390 | | 1 | 操作成功 | 391 | | 2 | 操作失败 | 392 | | 10001 | 未知异常导致无法唤醒MYKEY | 393 | | 10002 | MYKEY未安装 | 394 | | 10003 | MYKEY账户被冻结 | 395 | | 10004 | 未初始化 | 396 | | 10005 | 转账或合约方法调用上链超时 | 397 | | 10006 | 已经绑定过,执行绑定操作时抛出 | 398 | | 10007 | 未绑定,执行方法操作时抛出 | 399 | | 10008 | dapp已绑定,但是MYKEY未绑定,执行方法操作时抛出 | 400 | | 10009 | MYKEY已绑定,执行绑定操作时抛出 | 401 | | 10010 | dapp与MYKEY都已绑定,但是并不匹配 | 402 | | 10011 | MYKEY未注册,执行方法操作时抛出 | 403 | | 10012 | 参数非法 | 404 | | 10013 | 余额不足 | 405 | | 10014 | MYKEY账户不可用 | 406 | 407 | -------------------------------------------------------------------------------- /chinese/mykey_android_sdk.md: -------------------------------------------------------------------------------- 1 | # MYKEY Android SDK 2 | 3 | ## 如何集成 4 | 5 | ### 1. 在以下项目链接中,下载MYKEYWalletLib.aar文件,复制到到你app模块的libs目录下 6 | 7 | [https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/Android](https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/Android) 8 | 9 | ### 2. 在app模块的build.gradle文件的空白处添加如下代码: 10 | 11 | ```text 12 | repositories { 13 | flatDir { 14 | dirs 'libs' 15 | } 16 | } 17 | ``` 18 | 19 | ### 3. 在app模块的build.gradle文件android下添加Jni文件夹配置 20 | 21 | ```text 22 | android { 23 | ... 24 | sourceSets { 25 | main { 26 | jniLibs.srcDirs = ['libs'] 27 | } 28 | } 29 | defaultConfig { 30 | ndk { 31 | abiFilters "armeabi-v7a" 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | ### 4. 在app模块的build.gradle文件中添加依赖 38 | 39 | ```text 40 | dependencies{ 41 | implementation(name: 'MYKEYWalletLib', ext: 'aar') 42 | implementation "com.alibaba:fastjson:1.1.70.android" 43 | } 44 | ``` 45 | 46 | ### 5. 复制下面的代码到你的AndroidManifest.xml,并设置符合你包名或规则的scheme、host和path 47 | 48 | ```markup 49 | 50 | 51 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | ``` 63 | 64 | 此设置会为你生成一个供MYKEY调用的深度链接,在MYKEY初始化时会用到,[init](mykey_android_sdk.md#init) [initSimple](mykey_android_sdk.md#initSimple)。 65 | 66 | ### 6. 添加混淆配置 67 | 68 | ```text 69 | -keep class com.mykey.sdk**{*;} 70 | -dontwarn com.mykey.sdk** 71 | 72 | -keep class go**{*;} 73 | -dontwarn go** 74 | 75 | -keep class mykeycore**{*;} 76 | -dontwarn mykeycore** 77 | ``` 78 | 79 | ## Class MyKeySdk 80 | 81 | MYKEY Android主要的逻辑封装在MyKeySdk类中, 实现了6个方法,分别是init, initSimple, authorize, transfer, contract, signature, jumpToGuideInstall. 82 | 83 | ### 方法描述 Method Summary 84 | 85 | | Methods | 86 | | :---: | 87 | | [init](mykey_android_sdk.md#init) | 88 | | [initSimple](mykey_android_sdk.md#initsimple) | 89 | | [authorize](mykey_android_sdk.md#authorize) | 90 | | [transfer](mykey_android_sdk.md#transfer) | 91 | | [contract](mykey_android_sdk.md#contract) | 92 | | [sign](mykey_android_sdk.md#sign) | 93 | | [jumpToGuideInstall](mykey_android_sdk.md#jumptoguideinstall) | 94 | 95 | ### init 96 | 97 | 实例化MyKeySdk类,MYKEY双向绑定认证方式调用,在主进程中进行SDK初始化,使用此初始化方法,dapp如果存在账户体系,可以与MYKEY进行绑定操作。参数请详见类定义: [InitRequest](mykey_android_sdk.md#class-initrequest) 98 | 99 | ```java 100 | MYKEYSdk.getInstance().init(new InitRequest().setAppKey(Config.SAMPLE_DAPP_APP_KEY) 101 | .setDappName(Config.SAMPLE_DAPP_NAME) 102 | .setUuid(Config.SAMPLE_DAPP_USER_ID) 103 | .setDappIcon(Config.SAMPLE_DAPP_ICON) 104 | .setCallback(Config.SAMPLE_DAPP_CALLBACK) 105 | .setDsiableInstall(false) 106 | .setContractPromptFree(true) 107 | .setContext(this)); 108 | ``` 109 | 110 | ### initSimple 111 | 112 | 实例化MyKeySdk类,MYKEY轻量级认证方式调用,在主进程中进行SDK初始化,底层使用simplewallet协议逻辑,使用此初始化方法,dapp可以没有账户体系,不需要与MYKEY进行绑定操作。参数请详见类定义: [InitSimpleRequest](mykey_android_sdk.md#class-initsimplerequest) 113 | 114 | ```java 115 | MYKEYSdk.getInstance().initSimple(new InitSimpleRequest().setDappName(Config.SAMPLE_DAPP_NAME) 116 | .setDappIcon(Config.SAMPLE_DAPP_ICON) 117 | .setCallback(Config.SAMPLE_DAPP_CALLBACK) 118 | .setDisableInstall(false) 119 | .setContractPromptFree(true) 120 | .setContext(this)); 121 | ``` 122 | 123 | ### authorize 124 | 125 | 唤起MYKEY进行认证绑定。参数请详见类定义: [AuthorizeRequest](mykey_android_sdk.md#class-authorizerequest) 和 [MYKEYWalletCallback](mykey_android_sdk.md#class-mykeywalletcallback) 126 | 127 | 为了更强的安全性,可以设置CallBackUrl进行服务端验签 128 | 129 | MYKEY将签名后的数据POST到dapp提供的CallBackUrl,请求dapp服务端验证,dapp服务端需要从合约数据中获取该用户在MYKEY的ReserveKey进行验签,获取方式参考[KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 130 | 131 | dapp提供的CallBackUrl接口参数: 132 | 133 | ```java 134 | { 135 | "protocol": "", // 协议名,使用MYKEY双向绑定方式协议为MYKEY,使用MYKEY轻量级方式协议为MYKEYSimple 136 | "version": "", // 协议版本信息,如1.0 137 | "dapp_key": "", // MYKEY分配的DAPP_KEY,使用MYKEY双向绑定方式时提供,由MYKEY服务端分配,从dapp客户端初始化方法传入 138 | "uuID": "", // 用户id,MYKEY双向绑定方式此字段为dapp客户端初始化时传入的uuid;MYKEY轻量级方式此字段为用户的设备ID; 139 | "sign": "", // eos签名, 签名数据:timestamp + account + uuID + ref 140 | "ref": "", // 来源, mykey 141 | "timestamp": "",// 当前UNIX时间戳, 精确到秒 142 | "account": "" // eos账户名 143 | } 144 | ``` 145 | 146 | 验签方式: 147 | 148 | ```javascript 149 | // generate unsignedMessage 150 | let unsignedData = timestamp + account + uuID + ref 151 | // publicKey: ReserveKey of MYKEY,can be quired from SmartContract https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata 152 | ecc.verify(signature, unsignedData, pubkey) === true 153 | ``` 154 | 155 | dapp提供的CallBackUrl接口返回值: 156 | 157 | ```java 158 | { 159 | "code": 0, // 错误符,等于0是成功,大于0说明请求失败,dapp返回具体的错误码 160 | "message": "" // 返回的提示信息 161 | } 162 | ``` 163 | 164 | 调用例子: 165 | 166 | ```java 167 | AuthorizeRequest authorizeRequest = new AuthorizeRequest() 168 | .setUserName("bobbobbobbob") 169 | // DApp CallbackUrl 170 | // param:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 171 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 172 | .setCallbackUrl(Config.DAPP_CALLBACK_URL) 173 | .setInfo("Perform the binding of dapp and MYKEY"); 174 | MYKEYSdk.getInstance().authorize(authorizeRequest, new MYKEYWalletCallback() { 175 | @Override 176 | public void onSuccess(String dataJson) { 177 | // dataJson:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 178 | LogUtil.e(TAG, "onSuccess"); 179 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 180 | // DApp此时需要去DApp server查询是否绑定成功 181 | } 182 | 183 | @Override 184 | public void onError(String payloadJson) { 185 | // payloadJson: {"errorCode":,"errorMsg":""} 186 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 187 | Toast.makeText(activity, "error,payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 188 | } 189 | 190 | @Override 191 | public void onCancel() { 192 | LogUtil.e(TAG, "cancel"); 193 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 194 | } 195 | }); 196 | ``` 197 | 198 | ### transfer 199 | 200 | 唤起MYKEY进行转账。参数请详见类定义: [TransferRequest](mykey_android_sdk.md#class-transferrequest) 和 [MYKEYWalletCallback](mykey_android_sdk.md#class-mykeywalletcallback) 201 | 202 | ```java 203 | TransferRequest transferRequest = new TransferRequest() 204 | .setFrom("bobbobbobbob") 205 | .setTo("alicealice11") 206 | .setAmount(0.0001) 207 | .setMemo("memo") 208 | .setContractName("eosio.token") 209 | .setSymbol("EOS") 210 | .setInfo("transfer to alicealice11") 211 | .setDecimal(4) 212 | // order ID which come from dapp server 213 | .setOrderId("BH1000001") 214 | // DApp CallbackUrl 215 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 216 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 217 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 218 | MYKEYSdk.getInstance().transfer(transferRequest, new MYKEYWalletCallback() { 219 | @Override 220 | public void onSuccess(String dataJson) { 221 | // dataJson:{"txId":""} 222 | LogUtil.e(TAG, "onSuccess data:" + dataJson); 223 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 224 | } 225 | 226 | @Override 227 | public void onError(String payloadJson) { 228 | // payloadJson: {"errorCode":,"errorMsg":""} 229 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 230 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 231 | } 232 | 233 | @Override 234 | public void onCancel() { 235 | LogUtil.e(TAG, "cancel"); 236 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 237 | } 238 | }); 239 | ``` 240 | 241 | ### contract 242 | 243 | 唤起MYKEY进行合约调用, 支持多Action组合调用, 支持ContractAction和TransferAction两种形式的action类型。 参数请详见类定义: [ContractRequest](mykey_android_sdk.md#class-contractrequest) 和 [MYKEYWalletCallback](mykey_android_sdk.md#class-mykeywalletcallback) 244 | 245 | ```java 246 | ContractRequest contractRequest = new ContractRequest() 247 | .setInfo("Perform the mortgage REX operation") 248 | // order ID which come from dapp server 249 | .setOrderId("BH1000001") 250 | // DApp CallbackUrl 251 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 252 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 253 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 254 | ContractAction contractActionRequest = new ContractAction(); 255 | contractActionRequest.setAccount("eosio") 256 | .setName("buyram") 257 | .setInfo("buy ram") 258 | // JSON string support, eg:setData("{\"player\":\"bobbobbobbob\",\"receiver\":\"alicealice11\",\"quant\":\"1.0000 EOS\"}") 259 | .setData(new BuyRamDataEntity().setPayer("bobbobbobbob").setReceiver("alicealice11").setQuant("1.0000 EOS")); 260 | contractRequest.addAction(contractActionRequest); 261 | 262 | TransferAction transferActionRequest = new TransferAction(); 263 | transferActionRequest.setAccount("eosio.token") 264 | .setName("transfer") 265 | .setInfo("transfer to alicealice11") 266 | .setData(new TransferData().setFrom("bobbobbobbob").setTo("alicealice11").setQuantity("0.0001 EOS").setMemo("memo")); 267 | contractRequest.addAction(transferActionRequest); 268 | 269 | MYKEYSdk.getInstance().contract(contractRequest, new MYKEYWalletCallback() { 270 | @Override 271 | public void onSuccess(String dataJson) { 272 | // dataJson:{"txId":""} 273 | LogUtil.e(TAG, "onSuccess"); 274 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 275 | } 276 | 277 | @Override 278 | public void onError(String payloadJson) { 279 | // payloadJson: {"errorCode":,"errorMsg":""} 280 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 281 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 282 | } 283 | 284 | @Override 285 | public void onCancel() { 286 | LogUtil.e(TAG, "cancel"); 287 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 288 | } 289 | }); 290 | ``` 291 | 292 | ### sign 293 | 294 | 唤起MYKEY进行Sign签名操作。参数请详见类定义: [SignRequest](mykey_android_sdk.md#class-signrequest) 和 [MYKEYWalletCallback](mykey_android_sdk.md#class-mykeywalletcallback) 295 | 296 | dapp服务端或者客户端需要从合约数据中获取该用户在MYKEY的ReserveKey进行验签,获取方式参考[KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 297 | 298 | ```java 299 | SignRequest signRequest = new SignRequest().setMessage("Messages that need to be signed, [it could be random which come from dapp server]") 300 | // DApp CallbackUrl 301 | // param:{"protocol": "", "version": "", "message": "", "sign": "", "ref": "", "account": ""} 302 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 303 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 304 | MYKEYSdk.getInstance().sign(signRequest, new MYKEYWalletCallback() { 305 | @Override 306 | public void onSuccess(String dataJson) { 307 | // dataJson:{"sign":""} 308 | LogUtil.e(TAG, "onSuccess data:" + dataJson); 309 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 310 | } 311 | 312 | @Override 313 | public void onError(String payloadJson) { 314 | // payloadJson: {"errorCode":,"errorMsg":""} 315 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 316 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 317 | } 318 | 319 | @Override 320 | public void onCancel() { 321 | LogUtil.e(TAG, "cancel"); 322 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 323 | } 324 | }); 325 | ``` 326 | 327 | ### jumpToGuideInstall 328 | 329 | 跳转到弹出引导安装MYKEY页面,当用户没有安装MYKEY时进行引导。 330 | 331 | ### 字段描述 Field Summary 332 | 333 | | Field | Type | Description | 334 | | :--- | :---: | :--- | 335 | | initHandle | com.mykey.sdk.handle.InitHandle | 实例化类的处理逻辑 | 336 | | authorizeHandle | com.mykey.sdk.handle.AuthorizeHandle | 认证操作的处理逻辑 | 337 | | transferHandle | com.mykey.sdk.handle.TransferHandle | 转账操作的处理逻辑 | 338 | | contractHandle | com.mykey.sdk.handle.ContractHandle | 合约操作的处理逻辑 | 339 | | signatureHandle | com.mykey.sdk.handle.SignatureHandle | 签名操作的处理逻辑 | 340 | 341 | ## 其他类定义 342 | 343 | ### Class InitRequest 344 | 345 | | properties | Type | Description | 346 | | :--- | :---: | :--- | 347 | | context | android.content.Context | 可传入dapp应用上下文 | 348 | | appKey | String | 为每一个dapp指定的唯一key | 349 | | uuid | UUID | dapp为该用户提供的唯一ID,建议使用uuid | 350 | | dappName | String | dapp的名称 | 351 | | dappIcon | String | dapp的logo, 建议不低于144x144px | 352 | | disableInstall(默认false) | boolean | 是否禁用MYKEY未安装时显示默认引导页面 | 353 | | callback | String | MYKEY调用成功后回调dapp的深度链接,在[AndroidManifest.xml中定义](mykey_android_sdk.md#4-复制下面的代码到你的androidmanifestxml并设置符合你包名或规则的schemehost和path), e.g. customscheme://customhost/custompath | 354 | | showUpgradeTip(默认false) | boolean | MYKEY非最新版本是否显示更新提示,提示为系统默认Toast | 355 | | mykeyServer | String | MYKEY服务端环境Endpoint | 356 | | contractPromptFree | Boolean | 除转账行为之外的合约方法免提示开关 | 357 | 358 | ### Class InitSimpleRequest 359 | 360 | | properties | Type | Description | 361 | | :--- | :---: | :--- | 362 | | context | android.content.Context | 可传入dapp应用上下文 | 363 | | dappName | String | dapp的名称 | 364 | | dappIcon | String | dapp的logo, 建议不低于144x144px | 365 | | disableInstall(默认false) | boolean | 是否禁用MYKEY未安装时显示默认引导页面 | 366 | | callback | String | MYKEY调用成功后回调dapp的深度链接,在[AndroidManifest.xml中定义](mykey_android_sdk.md#4-复制下面的代码到你的androidmanifestxml并设置符合你包名或规则的schemehost和path), e.g. customscheme://customhost/custompath | 367 | | contractPromptFree | Boolean | 除转账行为之外的合约方法免提示开关 | 368 | 369 | ### Class AuthorizeRequest 370 | 371 | | properties | Type | Description | 372 | | :--- | :---: | :--- | 373 | | userName | String | 自定义用户名 | 374 | | callBackUrl(可选) | String | dapp server的回调url,MYKEY绑定成功会先回调dapp server,然后再唤醒移动端 | 375 | | info | String | 备注信息,用于绑定认证页面的语义化描述 | 376 | 377 | ### Class TransferRequest 378 | 379 | | properties | Type | Description | 380 | | :--- | :---: | :--- | 381 | | from | String | 转账账户 | 382 | | to | String | 接受账户 | 383 | | amount | String | 转账数量 | 384 | | symbol | String | 币种Symbol, e.g. "EOS" | 385 | | contractName | String | 合约名称, e.g. "eosio.token" | 386 | | decimal | String | 币种对应的小数位数 | 387 | | memo | String | 链上的MEMO备注 | 388 | | info | String | 备注信息,用于语义化该笔转账交易 | 389 | | orderId | String | 订单ID,dapp提供的订单ID,可为空 e.g. "20190606001" | 390 | | callbackUrl(可选) | String | dapp server的回调url,上链成功会先回调dapp server,然后再唤醒移动端 | 391 | 392 | ### Class ContractRequest 393 | 394 | | properties | Type | Description | 395 | | :--- | :---: | :--- | 396 | | orderId | String | dapp 提供的订单ID, 可为空 | 397 | | info | String | 备注信息,用于语义化该笔操作 | 398 | | callbackUrl(可选) | String | dapp server的回调url,上链成功会先回调dapp server,然后再唤醒移动端 | 399 | | list\ | [ContractAction](mykey_android_sdk.md#class-contractaction) 或者 [TransferAction](mykey_android_sdk.md#class-transferaction) | 合约操作action的列表 | 400 | 401 | ### Class ContractAction 402 | 403 | | properties | Type | Description | 404 | | :--- | :---: | :--- | 405 | | account | String | 合约名 | 406 | | name | String | 合约方法 | 407 | | info | String | 备注信息,用于语义化该笔操作 | 408 | | data | Object | 根据合约abi定义所传的参数对象 e.g. {key1: value1, key2: value2 } | 409 | 410 | ### Class TransferAction 411 | 412 | | properties | Type | Description | 413 | | :--- | :---: | :--- | 414 | | account | String | 合约名 | 415 | | name | String | 合约方法,填写"transfer" | 416 | | info | String | 备注信息,用于语义化该笔操作 | 417 | | transferObj | [TransferData](mykey_android_sdk.md#class-transferdata) | 转账信息对象 | 418 | 419 | ### Class TransferData 420 | 421 | | properties | Type | Description | 422 | | :--- | :---: | :--- | 423 | | from | String | 转账支出账号 | 424 | | to | String | 转账接收账号 | 425 | | quantity | String | 转账金额与单位 | 426 | | memo | String | 链上备注信息 | 427 | 428 | ### Class SignRequest 429 | 430 | | properties | Type | Description | 431 | | :--- | :---: | :--- | 432 | | message | String | 需要签名的数据 | 433 | | callbackUrl | String | dapp server的回调url,MYKEY绑定成功会先回调dapp server,然后再唤醒移动端 | 434 | 435 | ### Class MYKEYWalletCallback 436 | 437 | | methods | Description | 438 | | :--- | :--- | 439 | | onSuccess | 成功的回调 | 440 | | onError | 失败的回调,[errorCode列表](mykey_android_sdk.md#error-code) | 441 | | onCancel | 取消交易的回调 | 442 | 443 | ## Error Code 444 | 445 | 0-2为SimpleWallet定义字段 446 | 447 | 10001-X为MYKEYSdk定义字段 448 | 449 | | code | Description | 450 | | :--- | :--- | 451 | | 0 | 用户主动取消操作 | 452 | | 1 | 操作成功 | 453 | | 2 | 操作失败 | 454 | | 10001 | 未知异常导致无法唤醒MYKEY | 455 | | 10002 | MYKEY未安装 | 456 | | 10003 | MYKEY账户被冻结 | 457 | | 10004 | 未初始化 | 458 | | 10005 | 转账或合约方法调用上链超时 | 459 | | 10006 | 已经绑定过,执行绑定操作时抛出 | 460 | | 10007 | 未绑定,执行方法操作时抛出 | 461 | | 10008 | dapp已绑定,但是MYKEY未绑定,执行方法操作时抛出 | 462 | | 10009 | MYKEY已绑定,执行绑定操作时抛出 | 463 | | 10010 | dapp与MYKEY都已绑定,但是并不匹配 | 464 | | 10011 | MYKEY未注册,执行方法操作时抛出 | 465 | | 10012 | 参数非法 | 466 | | 10013 | 余额不足 | 467 | | 10014 | MYKEY账户不可用 | 468 | 469 | -------------------------------------------------------------------------------- /english/mykey_ios_sdk_en.md: -------------------------------------------------------------------------------- 1 | # MYKEY iOS SDK 2 | 3 | ## 1. How to integration 4 | 5 | ### 1.1 Download MYKEYWalletLib-iOS.zip from following link, unzip and place it into your project 6 | 7 | [https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/iOS](https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/iOS) 8 | 9 | ### 1.2 Setup URL scheme in Xcode: Goto "Project->TARGETS->info->URL Types", click "add icon". 10 | 11 | For example, use 'demoscheme' as follows 12 | 13 | ![](../.gitbook/assets/iosurltypes.jpg) 14 | 15 | This configuration will generate a deeplink for MYKEY callback, which will be used in MYKEK SDK initlization. [See initWallet](mykey_ios_sdk_en.md#initwallet) and [See initWalletSimple](mykey_ios_sdk_en.md#initwalletsimple). 16 | 17 | ### 1.3 Add one more option on "LSApplicationQueriesSchemes" in info.plist, the value is "mykey" 18 | 19 | ![](../.gitbook/assets/ioslsapplicationqueriesschemes.jpg) 20 | 21 | ### 1.4 Set "Enable Bitcode" to "false" in Build settings 22 | 23 | ![](../.gitbook/assets/iosbitcode.jpg) 24 | 25 | ### 1.5 Note 26 | 27 | This library is using swift code, if your application is Objective-C project will need some special configuration 28 | 29 | Project are required to create one empty swift file in project. For example, Empty.swift, meanwhile project will auto generate corresponding \ file. ![](../.gitbook/assets/iosbridging%20%281%29.jpg) 30 | 31 | ## 2. Initialize 32 | 33 | ### 2.1 Add "MYKEYWalletLib.h" file in "AppDelegate.m" 34 | 35 | #### In swift 36 | 37 | ```text 38 | import MYKEYWalletLib 39 | ``` 40 | 41 | #### In Objective-C 42 | 43 | ```text 44 | #import 45 | ``` 46 | 47 | ### 2.2 Init 48 | 49 | ```text 50 | let initData = InitRequest() 51 | initData.appKey = "xxxx" 52 | initData.dappName = "DappNameA" 53 | initData.dappIcon = "https:.../xx.png" 54 | initData.UUID = UUID 55 | initData.scheme = "demoscheme" 56 | initData.disableInstall = true 57 | MYKEYWallet.shared.initWallet(initData: initData) 58 | ``` 59 | 60 | For the param scheme, [refer scheme configuration in 1.2](mykey_ios_sdk_en.md#12-setup-url-scheme-in-xcode-goto-project-targets-info-url-types-click-add-icon) 61 | 62 | ### 2.3 Invoke handlerUrl in "application:openURL:" 63 | 64 | ```text 65 | MYKEYWallet.shared.handleUrl(url: url) 66 | ``` 67 | 68 | ## Class MYKEYWallet 69 | 70 | MYKEY iOS SDK's main logic is encapsulated in the MYKEYWallet class, which implements six methods, namely initWallet, initWalletSimple, authorize, transfer, contract, sign. 71 | 72 | ### Method Summary 73 | 74 | | Methods | 75 | | :---: | 76 | | [initWallet](mykey_ios_sdk_en.md#initwallet) | 77 | | [initWalletSimple](mykey_ios_sdk_en.md#initwalletsimple) | 78 | | [authorize](mykey_ios_sdk_en.md#authorize) | 79 | | [transfer](mykey_ios_sdk_en.md#transfer) | 80 | | [contract](mykey_ios_sdk_en.md#contract) | 81 | | [sign](mykey_ios_sdk_en.md#sign) | 82 | 83 | ### initWallet 84 | 85 | Instantiate the class MYKEYWallet, initialize the SDK in the main process, use this initialization method, if dapp already have an account system, you can bind with MYKEY. See the class definition for the parameters: [InitRequest](mykey_ios_sdk_en.md#class-initrequest) 86 | 87 | ```text 88 | let initData = InitRequest() 89 | initData.appKey = "xxxx" 90 | initData.dappName = "DappNameA" 91 | initData.dappIcon = "https:.../xx.png" 92 | initData.UUID = "uuidxxxxx" 93 | initData.scheme = "demoscheme" 94 | initData.disableInstall = true 95 | MYKEYWallet.shared.initWallet(initData: initData) 96 | ``` 97 | 98 | For the param scheme, [refer scheme configuration in 1.2](mykey_ios_sdk_en.md#12-setup-url-scheme-in-xcode-goto-project-targets-info-url-types-click-add-icon) 99 | 100 | ### initWalletSimple 101 | 102 | Instantiate the class MYKEYWallet, initialize the SDK in the main process, and use the simplewallet protocol logic at the bottom layler. Using this initialization method, the dapp can have no account system, without deep bind with MYKEY account. See the class definition for the parameters: [InitSimpleRequest](mykey_ios_sdk_en.md#class-initsimplerequest) 103 | 104 | ```text 105 | let initSimpleData = InitSimpleRequest() 106 | initSimpleData.dappName = "DappNameA" 107 | initSimpleData.dappIcon = "hhttps:.../xx.png" 108 | initSimpleData.scheme = "demoscheme" 109 | initSimpleData.disableInstall = true 110 | MYKEYWallet.shared.initWalletSimple(initSimpleData: initSimpleData) 111 | ``` 112 | 113 | For the param scheme, [refer scheme configuration in 1.2](mykey_ios_sdk_en.md#12-setup-url-scheme-in-xcode-goto-project-targets-info-url-types-click-add-icon) 114 | 115 | ### authorize 116 | 117 | Pull up MYKEY for authentication binding. See the class definition for the parameters: [AuthorizeRequest](mykey_ios_sdk_en.md#class-authorizerequest) and [MYKEYResponse](mykey_ios_sdk_en.md#class-mykeyresponse) 118 | 119 | For greater security, dapp can set CallBackUrl for server-side verification. 120 | 121 | MYKEY will post the signed data to CallBackUrl which provided by dapp, server-side of dapp should verify the signature, dapp server should query the user's ReserveKey from MYKEY SmartContract data to verify the signature, see detail in [KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 122 | 123 | The format of the data post to CallBackUrl 124 | 125 | ```java 126 | { 127 | "protocol": "", // protocol name,Use init method, protocol name is 'MYKEY', use initSimple to init, protocol name is 'MYKEYSimple' 128 | "version": "", // Version,1.0 129 | "dapp_key": "", // DAPP_KEY assigned by MYKEY,contact MYKEY team to apply. In simple mode, it is null 130 | "uuID": "", // user id,dapp passed it in init method;In simple mode, it is device id 131 | "sign": "", // eos signature, sign data:timestamp + account + uuID + ref 132 | "ref": "", // ref, mykey 133 | "timestamp": "",// UNIX timestamp, accurate to second 134 | "account": "" // eos account name 135 | } 136 | ``` 137 | 138 | Verify signature: 139 | 140 | ```javascript 141 | // generate unsignedMessage 142 | let unsignedData = timestamp + account + uuID + ref 143 | // publicKey: ReserveKey of MYKEY,can be quired from SmartContract https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata 144 | ecc.verify(signature, unsignedData, pubkey) === true 145 | ``` 146 | 147 | dapp should provide response of CallBackUrl call to MYKEY 148 | 149 | ```java 150 | { 151 | "code": 0, // error code,=0 is success. >0, dapp should describe error in message. 152 | "message": "" // message 153 | } 154 | ``` 155 | 156 | Sample 157 | 158 | ```text 159 | let authorizeRequest = AuthorizeRequest() 160 | authorizeRequest.userName = "uchihamadara" 161 | authorizeRequest.info = "Test information" 162 | // param:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 163 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 164 | authorizeRequest.callbackUrl = "https://dappserver.xxx.url" 165 | 166 | MYKEYWallet.shared.authorize(authorizeRequest: authorizeRequest, response: MYKEYResponse.init(success: { (response) in 167 | self.view.makeToast("success") 168 | }, failure: { (errorValue) in 169 | self.view.makeToast("failure") 170 | }, cancelled: { 171 | self.view.makeToast("cancelled") 172 | })) 173 | ``` 174 | 175 | ### transfer 176 | 177 | Pull up MYKEY to transfer. See the class definition for the parameters: [TransferRequest](mykey_ios_sdk_en.md#class-transferrequest) or [MYKEYResponse](mykey_ios_sdk_en.md#class-mykeyresponse) 178 | 179 | ```text 180 | let transferData = TransferData() 181 | transferData.from = "mykeyhulu525" 182 | transferData.to = "madaraxliang" 183 | transferData.quantity = "1.31 EOS" 184 | transferData.memo = "transfer-memo" 185 | 186 | let transferActionData = TransferAction() 187 | transferActionData.account = "eosio.token" 188 | transferActionData.name = WalletActionConstants.TRANSFER.rawValue 189 | transferActionData.info = "contract-transfer-info" 190 | transferActionData.data = transferData 191 | 192 | let contractActionData = ContractAction() 193 | contractActionData.account = "eosio" 194 | contractActionData.name = "buyram" 195 | contractActionData.info = "contract-contract-info" 196 | contractActionData.data = ["payer":"mykeyhulu123","receiver":"mykeyhulu111","quant":"1.01 EOS"] 197 | 198 | let contractRequest = ContractRequest() 199 | contractRequest.info = "Perform the mortgage REX operation" 200 | contractRequest.orderId = "BH19004" 201 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 202 | contractRequest.callbackUrl = "https://dappserver.xxx.url" 203 | contractRequest.actions = [transferActionData,contractActionData] 204 | 205 | MYKEYWallet.shared.contract(contractRequest: contractRequest, response: MYKEYResponse.init(success: { (response) in 206 | self.view.makeToast("success") 207 | }, failure: { (errorValue) in 208 | self.view.makeToast("failure") 209 | }, cancelled: { 210 | self.view.makeToast("cancelled") 211 | })) 212 | ``` 213 | 214 | ### contract 215 | 216 | Pull up MYKEY for contract calls, support multiple action combination calls, support ContractAction and TransferAction two types of action types. Please refer to the class definition for the parameters [ContractRequest](mykey_ios_sdk_en.md#class-contractrequest), [ContractAction](mykey_ios_sdk_en.md#class-contractaction) , [TransferAction](mykey_ios_sdk_en.md#class-transferaction) and [MYKEYResponse](mykey_ios_sdk_en.md#class-mykeyresponse). 217 | 218 | ```text 219 | let transferData = TransferData() 220 | transferData.from = "mykeyhulu525" 221 | transferData.to = "madaraxliang" 222 | transferData.quantity = "1.31 EOS" 223 | transferData.memo = "transfer-memo" 224 | 225 | let transferActionData = TransferAction() 226 | transferActionData.account = "eosio.token" 227 | transferActionData.name = WalletActionConstants.TRANSFER.rawValue 228 | transferActionData.info = "contract-transfer-info" 229 | transferActionData.data = transferData 230 | 231 | let contractActionData = ContractAction() 232 | contractActionData.account = "eosio" 233 | contractActionData.name = "buyram" 234 | contractActionData.info = "contract-contract-info" 235 | contractActionData.data = ["payer":"mykeyhulu123","receiver":"mykeyhulu111","quant":"1.01 EOS"] 236 | 237 | let contractRequest = ContractRequest() 238 | contractRequest.info = "Perform the mortgage REX operation" 239 | contractRequest.orderId = "BH19004" 240 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 241 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 242 | contractRequest.callbackUrl = "https://dappserver.xxx.url" 243 | contractRequest.actions = [transferActionData,contractActionData] 244 | 245 | MYKEYWallet.shared.contract(contractRequest: contractRequest, response: MYKEYResponse.init(success: { (response) in 246 | self.presentDataView(data: response) 247 | self.view.makeToast("success") 248 | }, failure: { (errorValue) in 249 | self.presentDataView(data: errorValue) 250 | self.view.makeToast("failure") 251 | }, cancelled: { 252 | self.view.makeToast("cancelled") 253 | })) 254 | ``` 255 | 256 | ### sign 257 | 258 | Pull up MYKEY for Signature operation. See the class definition for the parameters: [SignRequest](mykey_ios_sdk_en.md#class-signrequest) 259 | 260 | dapp server or client should query the user's ReserveKey from MYKEY SmartContract data to verify the signature, see detail in [KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 261 | 262 | ```text 263 | let signRequest = SignRequest() 264 | signRequest.message = "Messages that need to be signed, [it could be random which come from dapp server]" 265 | // DApp CallbackUrl 266 | // param:{"protocol": "", "version": "", "message": "", "sign": "", "ref": "", "account": ""} 267 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 268 | signRequest.callbackUrl = "https://dappserver.xxx.url" 269 | 270 | MYKEYWallet.shared.sign(signRequest: signRequest, response: MYKEYResponse.init(success: { (response) in 271 | self.view.makeToast("success") 272 | }, failure: { (errorValue) in 273 | self.view.makeToast("failure") 274 | }, cancelled: { 275 | self.view.makeToast("cancelled") 276 | })) 277 | ``` 278 | 279 | ## Other Class Defination 280 | 281 | ### Class InitRequest 282 | 283 | | properties | Type | Description | 284 | | :--- | :---: | :--- | 285 | | appKey | String | unique id assigned to each dapp, contact us | 286 | | UUID | UUID | the unique user id in dapp server side, recommend to use uuid | 287 | | dappName | String | dapp name | 288 | | dappIcon | String | dapp icon logo, no small than 144x144px | 289 | | disableInstall | boolean | Default: false, Whether to disable the default install page when MYKEY is not installed | 290 | | scheme | String | Deeplink MYKEY callback to dapp,defined in [refer scheme configuration in 1.2](mykey_ios_sdk_en.md#12-setup-url-scheme-in-xcode-goto-project-targets-info-url-types-click-add-icon), e.g. demoscheme | 291 | 292 | ### Class InitSimpleRequest 293 | 294 | | properties | Type | Description | 295 | | :--- | :---: | :--- | 296 | | dappName | String | dapp name | 297 | | dappIcon | String | dapp icon logo, no small than 144x144px | 298 | | disableInstall | boolean | Default: false, Whether to disable the default install page when MYKEY is not installed | 299 | | scheme | String | Deeplink MYKEY callback to dapp,defined in [refer scheme configuration in 1.2](mykey_ios_sdk_en.md#12-setup-url-scheme-in-xcode-goto-project-targets-info-url-types-click-add-icon), e.g. demoscheme | 300 | 301 | ### Class AuthorizeRequest 302 | 303 | | properties | Type | Description | 304 | | :--- | :---: | :--- | 305 | | userName | String | Custom user name | 306 | | callBackUrl | String | Optional, Callback endpoint url of dapp server,MYKEY will callback to dapp server after authorize request success at first, then wake up mobile client | 307 | | info | String | Info, Semantic description of MYKEY display to the user for authorization page | 308 | 309 | ### Class TransferRequest 310 | 311 | | properties | Type | Description | 312 | | :--- | :---: | :--- | 313 | | from | String | From account | 314 | | to | String | To account | 315 | | amount | String | Amount, e.g "1.0000" | 316 | | symbol | String | Symbol, e.g. "EOS" | 317 | | contractName | String | contract code name, e.g. "eosio.token" | 318 | | decimal | String | Decimal | 319 | | memo | String | Memo | 320 | | info | String | Semantic description of MYKEY display to the user about this transfer action | 321 | | orderId | String | The order id from dapp, optional, can be null, e.g. "20190606001" | 322 | | callbackUrl | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after transfer request success at first, then wake up mobile client | 323 | 324 | ### Class ContractRequest 325 | 326 | | properties | Type | Description | 327 | | :--- | :---: | :--- | 328 | | orderId | String | The order id from dapp, optional, can be null | 329 | | info | String | Semantic description of MYKEY display to the user about this action | 330 | | callbackUrl | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after contract request success at first, then wake up mobile client | 331 | | actions: \[BaseAction\] | [ContractAction](mykey_ios_sdk_en.md#class-contractaction) or [TransferAction](mykey_ios_sdk_en.md#class-transferaction) | List of contract actions | 332 | 333 | ### Class ContractAction 334 | 335 | | properties | Type | Description | 336 | | :--- | :---: | :--- | 337 | | account | String | contract code name | 338 | | name | String | contract action name | 339 | | info | String | Semantic description of MYKEY display to the user about this action | 340 | | data | Any | The parameter object passed according to the contract abi definition,this any type should be valid by JSONSerialization.isValidJSONObject\(\_ obj: Any\), e.g. {key1: value1, key2: value2 } | 341 | 342 | ### Class TransferAction 343 | 344 | | properties | Type | Description | 345 | | :--- | :---: | :--- | 346 | | account | String | contract code name | 347 | | name | String | contract action name, use "transfer" | 348 | | info | String | Semantic description of MYKEY display to the user about this action | 349 | | data | [TransferData](mykey_ios_sdk_en.md#class-transferdata) | Transfer info object | 350 | 351 | ### Class TransferData 352 | 353 | | properties | Type | Description | 354 | | :--- | :---: | :--- | 355 | | from | String | From account | 356 | | to | String | To account | 357 | | quantity | String | Amount and Symbol | 358 | | memo | String | Memo | 359 | 360 | ### Class SignRequest 361 | 362 | | properties | Type | Description | 363 | | :--- | :---: | :--- | 364 | | message | String | Unsigned messages | 365 | | callbackUrl | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after sign request success at first, then wake up mobile client | 366 | 367 | ### Class MYKEYResponse 368 | 369 | | properties | Description | 370 | | :--- | :--- | 371 | | success | Success Callback | 372 | | failure | Failure Callback, [errorCode list](mykey_ios_sdk_en.md#error-code) | 373 | | cancelled | Cancel Callback | 374 | 375 | ### Class MYKEYApiResponse 376 | 377 | | properties | Description | 378 | | :--- | :--- | 379 | | success | Success Callback | 380 | | failure | Failure Callback | 381 | 382 | ## Error Code 383 | 384 | 0-2 are defined by SimpleWallet 385 | 386 | 10001-X are defined by MYKEYSdk 387 | 388 | | code | Description | 389 | | :--- | :--- | 390 | | 0 | User cancel the transaction | 391 | | 1 | Success | 392 | | 2 | Failure | 393 | | 10001 | unknow issue lead can not wakeup MYKEY | 394 | | 10002 | MYKEY not installed yet | 395 | | 10003 | MYKEY account is frozen | 396 | | 10004 | Uninitialized | 397 | | 10005 | Push transaction timeout | 398 | | 10006 | Binded, triggered at authorize | 399 | | 10007 | Unbind, triggered at transaction, trasnfer, sign | 400 | | 10008 | dapp binded, and MYKEY unbind, triggered at transaction, trasnfer, sign | 401 | | 10009 | MYKEY binded, triggered at authorize | 402 | | 10010 | dapp binded, and MYKEY binded, but not match | 403 | | 10011 | MYKEY unregistered, triggered at transaction, trasnfer, sign | 404 | | 10012 | Illegal param | 405 | | 10013 | Insufficient balance | 406 | | 10014 | MYKEY account unavailable | 407 | 408 | -------------------------------------------------------------------------------- /english/mykey_android_sdk_en.md: -------------------------------------------------------------------------------- 1 | # MYKEY Android SDK 2 | 3 | ## How to integration 4 | 5 | ### 1. Download 'MYKEYWalletLib.aar' from following link, copy to libs directory of your app module 6 | 7 | [https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/Android](https://github.com/mykeylab/MYKEY-Client-SDK/tree/master/Android) 8 | 9 | ### 2. Add following code to file build.gradle: 10 | 11 | ```text 12 | repositories { 13 | flatDir { 14 | dirs 'libs' 15 | } 16 | } 17 | ``` 18 | 19 | ### 3. In file build.gradle, add config for Jni directory 20 | 21 | ```text 22 | android { 23 | ... 24 | sourceSets { 25 | main { 26 | jniLibs.srcDirs = ['libs'] 27 | } 28 | } 29 | 30 | defaultConfig { 31 | ndk { 32 | abiFilters "armeabi-v7a" 33 | } 34 | } 35 | 36 | } 37 | ``` 38 | 39 | ### 4. Add following dependency in file build.gradle 40 | 41 | ```text 42 | dependencies{ 43 | implementation(name: 'MYKEYWalletLib', ext: 'aar') 44 | implementation "com.alibaba:fastjson:1.1.70.android" 45 | } 46 | ``` 47 | 48 | ### 5. Copy following code to AndroidManifest.xml, and set the callback deeplink, composed by scheme、host and path 49 | 50 | ```markup 51 | 52 | 53 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | ``` 65 | 66 | This configuration will generate a deeplink for MYKEY callback, which will be used in MYKEK SDK initlization, [init](mykey_android_sdk_en.md#init) [initSimple](mykey_android_sdk_en.md#initSimple). 67 | 68 | ### 6. Proguard rules 69 | 70 | ```text 71 | -keep class com.mykey.sdk**{*;} 72 | -dontwarn com.mykey.sdk** 73 | 74 | -keep class go**{*;} 75 | -dontwarn go** 76 | 77 | -keep class mykeycore**{*;} 78 | -dontwarn mykeycore** 79 | ``` 80 | 81 | ## Class MyKeySdk 82 | 83 | MYKEY Android SDK's main logic is encapsulated in the MyKeySdk class, which implements six methods, namely init, initSimple, authorize, transfer, contract, signature, jumpToGuideInstall. 84 | 85 | ### Method Summary 86 | 87 | | Methods | 88 | | :---: | 89 | | [init](mykey_android_sdk_en.md#init) | 90 | | [initSimple](mykey_android_sdk_en.md#initsimple) | 91 | | [authorize](mykey_android_sdk_en.md#authorize) | 92 | | [transfer](mykey_android_sdk_en.md#transfer) | 93 | | [contract](mykey_android_sdk_en.md#contract) | 94 | | [sign](mykey_android_sdk_en.md#sign) | 95 | | [jumpToGuideInstall](mykey_android_sdk_en.md#jumptoguideinstall) | 96 | 97 | ### init 98 | 99 | Instantiate the class MyKeySdk, initialize the SDK in the main process, use this initialization method, if dapp already have an account system, you can bind with MYKEY. See the class definition for the parameters: [InitRequest](mykey_android_sdk_en.md#class-initrequest) 100 | 101 | ```java 102 | MYKEYSdk.getInstance().init(new InitRequest().setAppKey(Config.SAMPLE_DAPP_APP_KEY) 103 | .setDappName(Config.SAMPLE_DAPP_NAME) 104 | .setUuid(Config.SAMPLE_DAPP_USER_ID) 105 | .setDappIcon(Config.SAMPLE_DAPP_ICON) 106 | .setCallback(Config.SAMPLE_DAPP_CALLBACK) 107 | .setDsiableInstall(false) 108 | .setContractPromptFree(true) 109 | .setContext(this)); 110 | ``` 111 | 112 | ### initSimple 113 | 114 | Instantiate the class MyKeySdk, initialize the SDK in the main process, and use the simplewallet protocol logic at the bottom layler. Using this initialization method, the dapp can have no account system, without deep bind with MYKEY account. See the class definition for the parameters: [InitSimpleRequest](mykey_android_sdk_en.md#class-initsimplerequest) 115 | 116 | ```java 117 | MYKEYSdk.getInstance().initSimple(new InitSimpleRequest().setDappName(Config.SAMPLE_DAPP_NAME) 118 | .setDappIcon(Config.SAMPLE_DAPP_ICON) 119 | .setCallback(Config.SAMPLE_DAPP_CALLBACK) 120 | .setDisableInstall(false) 121 | .setContractPromptFree(true) 122 | .setContext(this)); 123 | ``` 124 | 125 | ### authorize 126 | 127 | Pull up MYKEY for authentication binding. See the class definition for the parameters: [AuthorizeRequest](mykey_android_sdk_en.md#class-authorizerequest) and [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 128 | 129 | For greater security, dapp can set CallBackUrl for server-side verification. 130 | 131 | MYKEY will post the signed data to CallBackUrl which provided by dapp, server-side of dapp should verify the signature, dapp server should query the user's ReserveKey from MYKEY SmartContract data to verify the signature, see detail in [KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 132 | 133 | The format of the data post to CallBackUrl 134 | 135 | ```java 136 | { 137 | "protocol": "", // protocol name,Use init method, protocol name is 'MYKEY', use initSimple to init, protocol name is 'MYKEYSimple' 138 | "version": "", // Version,1.0 139 | "dapp_key": "", // DAPP_KEY assigned by MYKEY,contact MYKEY team to apply. In simple mode, it is null 140 | "uuID": "", // user id,dapp passed it in init method;In simple mode, it is device id 141 | "sign": "", // eos signature, sign data:timestamp + account + uuID + ref 142 | "ref": "", // ref, mykey 143 | "timestamp": "",// UNIX timestamp, accurate to second 144 | "account": "" // eos account name 145 | } 146 | ``` 147 | 148 | Verify signature: 149 | 150 | ```javascript 151 | // generate unsignedMessage 152 | let unsignedData = timestamp + account + uuID + ref 153 | // publicKey: ReserveKey of MYKEY,can be quired from SmartContract https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata 154 | ecc.verify(signature, unsignedData, pubkey) === true 155 | ``` 156 | 157 | dapp should provide response of CallBackUrl call to MYKEY 158 | 159 | ```java 160 | { 161 | "code": 0, // error code,=0 is success. >0, dapp should describe error in message. 162 | "message": "" // message 163 | } 164 | ``` 165 | 166 | Sample 167 | 168 | ```java 169 | AuthorizeRequest authorizeRequest = new AuthorizeRequest() 170 | .setUserName("bobbobbobbob") 171 | // DApp CallbackUrl 172 | // param:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 173 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 174 | .setCallbackUrl(Config.DAPP_CALLBACK_URL) 175 | .setInfo("Perform the binding of dapp and MYKEY"); 176 | MYKEYSdk.getInstance().authorize(authorizeRequest, new MYKEYWalletCallback() { 177 | @Override 178 | public void onSuccess(String dataJson) { 179 | // dataJson:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 180 | LogUtil.e(TAG, "onSuccess"); 181 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 182 | //Add check code here, Check if bind success in dapp server 183 | } 184 | 185 | @Override 186 | public void onError(String payloadJson) { 187 | // payloadJson: {"errorCode":,"errorMsg":""} 188 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 189 | Toast.makeText(activity, "error,payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 190 | } 191 | 192 | @Override 193 | public void onCancel() { 194 | LogUtil.e(TAG, "cancel"); 195 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 196 | } 197 | }); 198 | ``` 199 | 200 | ### transfer 201 | 202 | Pull up MYKEY to transfer. See the class definition for the parameters: [TransferRequest](mykey_android_sdk_en.md#class-transferrequest) 和 [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 203 | 204 | ```java 205 | TransferRequest transferRequest = new TransferRequest() 206 | .setFrom("bobbobbobbob") 207 | .setTo("alicealice11") 208 | .setAmount(0.0001) 209 | .setMemo("memo") 210 | .setContractName("eosio.token") 211 | .setSymbol("EOS") 212 | .setInfo("transfer to alicealice11") 213 | .setDecimal(4) 214 | // order ID which come from dapp server 215 | .setOrderId("BH1000001") 216 | // DApp CallbackUrl 217 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 218 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 219 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 220 | MYKEYSdk.getInstance().transfer(transferRequest, new MYKEYWalletCallback() { 221 | @Override 222 | public void onSuccess(String dataJson) { 223 | // dataJson:{"txId":""} 224 | LogUtil.e(TAG, "onSuccess data:" + dataJson); 225 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 226 | } 227 | 228 | @Override 229 | public void onError(String payloadJson) { 230 | // payloadJson: {"errorCode":,"errorMsg":""} 231 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 232 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 233 | } 234 | 235 | @Override 236 | public void onCancel() { 237 | LogUtil.e(TAG, "cancel"); 238 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 239 | } 240 | }); 241 | ``` 242 | 243 | ### contract 244 | 245 | Pull up MYKEY for contract calls, support multiple action combination calls, support ContractAction and TransferAction two types of action types. Please refer to the class definition for the parameters [ContractRequest](mykey_android_sdk_en.md#class-contractrequest) and [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 246 | 247 | ```java 248 | ContractRequest contractRequest = new ContractRequest() 249 | .setInfo("Perform the mortgage REX operation") 250 | // order ID which come from dapp server 251 | .setOrderId("BH1000001") 252 | // DApp CallbackUrl 253 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 254 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 255 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 256 | ContractAction contractActionRequest = new ContractAction(); 257 | contractActionRequest.setAccount("eosio") 258 | .setName("buyram") 259 | .setInfo("buy ram") 260 | // JSON string support, eg:setData("{\"player\":\"bobbobbobbob\",\"receiver\":\"alicealice11\",\"quant\":\"1.0000 EOS\"}") 261 | .setData(new BuyRamDataEntity().setPayer("bobbobbobbob").setReceiver("alicealice11").setQuant("1.0000 EOS")); 262 | contractRequest.addAction(contractActionRequest); 263 | 264 | TransferAction transferActionRequest = new TransferAction(); 265 | transferActionRequest.setAccount("eosio.token") 266 | .setName("transfer") 267 | .setInfo("transfer to alicealice11") 268 | .setData(new TransferData().setFrom("bobbobbobbob").setTo("alicealice11").setQuantity("0.0001 EOS").setMemo("memo")); 269 | contractRequest.addAction(transferActionRequest); 270 | 271 | MYKEYSdk.getInstance().contract(contractRequest, new MYKEYWalletCallback() { 272 | @Override 273 | public void onSuccess(String dataJson) { 274 | // dataJson:{"txId":""} 275 | LogUtil.e(TAG, "onSuccess"); 276 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 277 | } 278 | 279 | @Override 280 | public void onError(String payloadJson) { 281 | // payloadJson: {"errorCode":,"errorMsg":""} 282 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 283 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 284 | } 285 | 286 | @Override 287 | public void onCancel() { 288 | LogUtil.e(TAG, "cancel"); 289 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 290 | } 291 | }); 292 | ``` 293 | 294 | ### sign 295 | 296 | Pull up MYKEY for Signature operation. See the class definition for the parameters: [SignRequest](mykey_android_sdk_en.md#class-signrequest) and [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 297 | 298 | dapp server or client should query the user's ReserveKey from MYKEY SmartContract data to verify the signature, see detail in [KEYS in MYKEY](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#keys-in-table-keydata) and [MYKEY Verify Sign](https://github.com/mykeylab/Documentation/blob/master/English/MYKEY%20on%20EOSIO.md#if-dapp-dependents-on-getarbitrarysignature-or-other-server-side-authentication) 299 | 300 | ```java 301 | SignRequest signRequest = new SignRequest().setMessage("Messages that need to be signed, [it could be random which come from dapp server]") 302 | // DApp CallbackUrl 303 | // param:{"protocol": "", "version": "", "message": "", "sign": "", "ref": "", "account": ""} 304 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 305 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 306 | MYKEYSdk.getInstance().sign(signRequest, new MYKEYWalletCallback() { 307 | @Override 308 | public void onSuccess(String dataJson) { 309 | // dataJson:{"sign":""} 310 | LogUtil.e(TAG, "onSuccess data:" + dataJson); 311 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 312 | } 313 | 314 | @Override 315 | public void onError(String payloadJson) { 316 | // payloadJson: {"errorCode":,"errorMsg":""} 317 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 318 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 319 | } 320 | 321 | @Override 322 | public void onCancel() { 323 | LogUtil.e(TAG, "cancel"); 324 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 325 | } 326 | }); 327 | ``` 328 | 329 | ### jumpToGuideInstall 330 | 331 | Jump to the pop-up to MYKEY installation page and boot when the user does not have MYKEY installed. 332 | 333 | ### Other Field Summary 334 | 335 | | Field | Type | Description | 336 | | :--- | :---: | :--- | 337 | | initHandle | com.mykey.sdk.handle.InitHandle | initialization implemented logic | 338 | | authorizeHandle | com.mykey.sdk.handle.AuthorizeHandle | Authorize implemented logic | 339 | | transferHandle | com.mykey.sdk.handle.TransferHandle | Transfer implemented logic | 340 | | contractHandle | com.mykey.sdk.handle.ContractHandle | Contract implemented logic | 341 | | signatureHandle | com.mykey.sdk.handle.SignatureHandle | Sign implemented logic | 342 | 343 | ## Other Class Defination 344 | 345 | ### Class InitRequest 346 | 347 | | properties | Type | Description | 348 | | :--- | :---: | :--- | 349 | | context | android.content.Context | dapp application context | 350 | | appKey | String | unique id assigned to each dapp, contact us | 351 | | uuid | UUID | the unique user id in dapp server side, recommend to use uuid | 352 | | dappName | String | dapp name | 353 | | dappIcon | String | dapp icon logo, no small than 144x144px | 354 | | disableInstall\(default false\) | boolean | Whether to disable the default install page when MYKEY is not installed | 355 | | callback | String | Deeplink MYKEY callback to dapp,defined in [AndroidManifest.xml](mykey_android_sdk_en.md#5-copy-following-code-to-androidmanifestxml-and-set-the-callback-deeplink-composed-by-schemehost-and-path), e.g. customscheme://customhost/custompath | 356 | | showUpgradeTip\(default false\) | boolean | Toast tip when MYKEY is not the latest version | 357 | | mykeyServer | String | Environment URL endpoint of MYKEY server | 358 | | contractPromptFree | Boolean | Do not display prompt for contract action except transfer | 359 | 360 | ### Class InitSimpleRequest 361 | 362 | | properties | Type | Description | 363 | | :--- | :---: | :--- | 364 | | context | android.content.Context | dapp application context | 365 | | dappName | String | dapp name | 366 | | dappIcon | String | dapp icon logo, no small than 144x144px | 367 | | disableInstall\(default false\) | boolean | Whether to disable the default install page when MYKEY is not installed | 368 | | callback | String | Deeplink MYKEY callback to dapp,defined in [AndroidManifest.xml](mykey_android_sdk_en.md), e.g. customscheme://customhost/custompath | 369 | | contractPromptFree | Boolean | Do not display prompt for contract action except transfer | 370 | 371 | ### Class AuthorizeRequest 372 | 373 | | properties | Type | Description | 374 | | :--- | :---: | :--- | 375 | | userName | String | Custom user name | 376 | | callBackUrl\(optional\) | String | Optional, Callback endpoint url of dapp server,MYKEY will callback to dapp server after authorize request success at first, then wake up mobile client | 377 | | info | String | Info, Semantic description of MYKEY display to the user for authorization page | 378 | 379 | ### Class TransferRequest 380 | 381 | | properties | Type | Description | 382 | | :--- | :---: | :--- | 383 | | from | String | From account | 384 | | to | String | To account | 385 | | amount | String | Amount, e.g "1.0000" | 386 | | symbol | String | Symbol, e.g. "EOS" | 387 | | contractName | String | contract code name, e.g. "eosio.token" | 388 | | decimal | String | Decimal | 389 | | memo | String | Memo | 390 | | info | String | Semantic description of MYKEY display to the user about this action | 391 | | orderId | String | The order id from dapp, optional, can be null e.g. "20190606001" | 392 | | callbackUrl\(optional\) | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after transfer request success at first, then wake up mobile client | 393 | 394 | ### Class ContractRequest 395 | 396 | | properties | Type | Description | 397 | | :--- | :---: | :--- | 398 | | orderId | String | The order id from dapp, optional, can be null | 399 | | info | String | Semantic description of MYKEY display to the user about this action | 400 | | callbackUrl\(optional\) | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after contract request success at first, then wake up mobile client | 401 | | list\ | [ContractAction](mykey_android_sdk_en.md#class-contractaction) or [TransferAction](mykey_android_sdk_en.md#class-transferaction) | List of contract actions | 402 | 403 | ### Class ContractAction 404 | 405 | | properties | Type | Description | 406 | | :--- | :---: | :--- | 407 | | account | String | contract code name | 408 | | name | String | contract action name | 409 | | info | String | Semantic description of MYKEY display to the user about this action | 410 | | data | Object | The parameter object passed according to the contract abi definition e.g. {key1: value1, key2: value2 } | 411 | 412 | ### Class TransferAction 413 | 414 | | properties | Type | Description | 415 | | :--- | :---: | :--- | 416 | | account | String | contract code name | 417 | | name | String | contract action name, use "transfer" | 418 | | info | String | Semantic description of MYKEY display to the user about this action | 419 | | transferObj | [TransferData](mykey_android_sdk_en.md#class-transferdata) | Transfer info object | 420 | 421 | ### Class TransferData 422 | 423 | | properties | Type | Description | 424 | | :--- | :---: | :--- | 425 | | from | String | From account name | 426 | | to | String | To account name | 427 | | quantity | String | Amount and Symbol | 428 | | memo | String | Memo | 429 | 430 | ### Class SignRequest 431 | 432 | | properties | Type | Description | 433 | | :--- | :---: | :--- | 434 | | message | String | Unsigned messages | 435 | | callbackUrl | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after sign request success at first, then wake up mobile client | 436 | 437 | ### Class MYKEYWalletCallback 438 | 439 | | methods | Description | 440 | | :--- | :--- | 441 | | onSuccess | Success Callback | 442 | | onError | Failure Callback,[errorCode list](mykey_android_sdk_en.md#error-code) | 443 | | onCancel | Cancel Callback | 444 | 445 | ## Error Code 446 | 447 | 0-2 are defined by SimpleWallet 448 | 449 | 10001-X are defined by MYKEYSdk 450 | 451 | | code | Description | 452 | | :--- | :--- | 453 | | 0 | User cancel the transaction | 454 | | 1 | Success | 455 | | 2 | Failure | 456 | | 10001 | unknow issue lead can not wakeup MYKEY | 457 | | 10002 | MYKEY not installed yet | 458 | | 10003 | MYKEY account is frozen | 459 | | 10004 | Uninitialized | 460 | | 10005 | Push transaction timeout | 461 | | 10006 | Binded, triggered at authorize | 462 | | 10007 | Unbind, triggered at transaction, trasnfer, sign | 463 | | 10008 | dapp binded, and MYKEY unbind, triggered at transaction, trasnfer, sign | 464 | | 10009 | MYKEY binded, triggered at authorize | 465 | | 10010 | dapp binded, and MYKEY binded, but not match | 466 | | 10011 | MYKEY unregistered, triggered at transaction, trasnfer, sign | 467 | | 10012 | Illegal param | 468 | | 10013 | Insufficient balance | 469 | 470 | ```text 471 | main { 472 | jniLibs.srcDirs = ['libs'] 473 | } 474 | } 475 | 476 | defaultConfig { 477 | ndk { 478 | abiFilters "armeabi-v7a" 479 | } 480 | } 481 | ``` 482 | 483 | } 484 | 485 | ```text 486 | ### 4. Add following dependency in file build.gradle 487 | ``` 488 | 489 | dependencies{ implementation\(name: 'MYKEYWalletLib', ext: 'aar'\) implementation "com.alibaba:fastjson:1.1.70.android" } 490 | 491 | ```text 492 | ### 5. Copy following code to AndroidManifest.xml, and set the callback deeplink, composed by scheme、host and path 493 | ```xml 494 | 495 | 496 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | ``` 508 | 509 | This configuration will generate a deeplink for MYKEY callback, which will be used in MYKEK SDK initlization, [init](mykey_android_sdk_en.md#init) [initSimple](mykey_android_sdk_en.md#initSimple). 510 | 511 | ### 6. Proguard rules 512 | 513 | ```text 514 | -keep class com.mykey.sdk**{*;} 515 | -dontwarn com.mykey.sdk** 516 | ``` 517 | 518 | ## Class MyKeySdk 519 | 520 | MYKEY Android SDK's main logic is encapsulated in the MyKeySdk class, which implements six methods, namely init, initSimple, authorize, transfer, contract, signature, jumpToGuideInstall. 521 | 522 | ### Method Summary 523 | 524 | | Methods | 525 | | :---: | 526 | | [init](mykey_android_sdk_en.md#init) | 527 | | [initSimple](mykey_android_sdk_en.md#initsimple) | 528 | | [authorize](mykey_android_sdk_en.md#authorize) | 529 | | [transfer](mykey_android_sdk_en.md#transfer) | 530 | | [contract](mykey_android_sdk_en.md#contract) | 531 | | [sign](mykey_android_sdk_en.md#sign) | 532 | | [jumpToGuideInstall](mykey_android_sdk_en.md#jumptoguideinstall) | 533 | 534 | ### init 535 | 536 | Instantiate the class MyKeySdk, initialize the SDK in the main process, use this initialization method, if dapp already have an account system, you can bind with MYKEY. See the class definition for the parameters: [InitRequest](mykey_android_sdk_en.md#class-initrequest) 537 | 538 | ```java 539 | MYKEYSdk.getInstance().init(new InitRequest().setAppKey(Config.SAMPLE_DAPP_APP_KEY) 540 | .setDappName(Config.SAMPLE_DAPP_NAME) 541 | .setUserId(Config.SAMPLE_DAPP_USER_ID) 542 | .setDappIcon(Config.SAMPLE_DAPP_ICON) 543 | .setCallback(Config.SAMPLE_DAPP_CALLBACK) 544 | .setDsiableInstall(false) 545 | .setContext(this)); 546 | ``` 547 | 548 | ### initSimple 549 | 550 | Instantiate the class MyKeySdk, initialize the SDK in the main process, and use the simplewallet protocol logic at the bottom layler. Using this initialization method, the dapp can have no account system, without deep bind with MYKEY account. See the class definition for the parameters: [InitSimpleRequest](mykey_android_sdk_en.md#class-initsimplerequest) 551 | 552 | ```java 553 | MYKEYSdk.getInstance().initSimple(new InitSimpleRequest().setDappName(Config.SAMPLE_DAPP_NAME) 554 | .setDappIcon(Config.SAMPLE_DAPP_ICON) 555 | .setCallback(Config.SAMPLE_DAPP_CALLBACK) 556 | .setDisableInstall(false) 557 | .setContext(this)); 558 | ``` 559 | 560 | ### authorize 561 | 562 | Pull up MYKEY for authentication binding. See the class definition for the parameters: [AuthorizeRequest](mykey_android_sdk_en.md#class-authorizerequest) and [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 563 | 564 | ```java 565 | AuthorizeRequest authorizeRequest = new AuthorizeRequest() 566 | .setUserName("bobbobbobbob") 567 | // DApp CallbackUrl 568 | // param:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 569 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 570 | .setCallbackUrl(Config.DAPP_CALLBACK_URL) 571 | .setInfo("Perform the binding of dapp and MYKEY"); 572 | MYKEYSdk.getInstance().authorize(authorizeRequest, new MYKEYWalletCallback() { 573 | @Override 574 | public void onSuccess(String dataJson) { 575 | // dataJson:{"protocol": "", "version": "", "dapp_key": "", "uuID": "", "public_key": "", "sign": "", "ref": "", "timestamp": "", "account": ""} 576 | LogUtil.e(TAG, "onSuccess"); 577 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 578 | //Add check code here, Check if bind success in dapp server 579 | } 580 | 581 | @Override 582 | public void onError(String payloadJson) { 583 | // payloadJson: {"errorCode":,"errorMsg":""} 584 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 585 | Toast.makeText(activity, "error,payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 586 | } 587 | 588 | @Override 589 | public void onCancel() { 590 | LogUtil.e(TAG, "cancel"); 591 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 592 | } 593 | }); 594 | ``` 595 | 596 | ### transfer 597 | 598 | Pull up MYKEY to transfer. See the class definition for the parameters: [TransferRequest](mykey_android_sdk_en.md#class-transferrequest) 和 [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 599 | 600 | ```java 601 | TransferRequest transferRequest = new TransferRequest() 602 | .setFrom("bobbobbobbob") 603 | .setTo("alicealice11") 604 | .setAmount(0.0001) 605 | .setMemo("memo") 606 | .setContractName("eosio.token") 607 | .setSymbol("EOS") 608 | .setInfo("transfer to alicealice11") 609 | .setDecimal(4) 610 | // order ID which come from dapp server 611 | .setOrderId("BH1000001") 612 | // DApp CallbackUrl 613 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 614 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 615 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 616 | MYKEYSdk.getInstance().transfer(transferRequest, new MYKEYWalletCallback() { 617 | @Override 618 | public void onSuccess(String dataJson) { 619 | // dataJson:{"txId":""} 620 | LogUtil.e(TAG, "onSuccess data:" + dataJson); 621 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 622 | } 623 | 624 | @Override 625 | public void onError(String payloadJson) { 626 | // payloadJson: {"errorCode":,"errorMsg":""} 627 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 628 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 629 | } 630 | 631 | @Override 632 | public void onCancel() { 633 | LogUtil.e(TAG, "cancel"); 634 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 635 | } 636 | }); 637 | ``` 638 | 639 | ### contract 640 | 641 | Pull up MYKEY for contract calls, support multiple action combination calls, support ContractAction and TransferAction two types of action types. Please refer to the class definition for the parameters [ContractRequest](mykey_android_sdk_en.md#class-contractrequest) and [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 642 | 643 | ```java 644 | ContractRequest contractRequest = new ContractRequest() 645 | .setInfo("Perform the mortgage REX operation") 646 | // order ID which come from dapp server 647 | .setOrderId("BH1000001") 648 | // DApp CallbackUrl 649 | // param:{"protocol": "", "version": "", "tx_id": "", "ref": "", "account": ""} 650 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 651 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 652 | ContractAction contractActionRequest = new ContractAction(); 653 | contractActionRequest.setAccount("eosio") 654 | .setName("buyram") 655 | .setInfo("buy ram") 656 | // JSON string support, eg:setData("{\"player\":\"bobbobbobbob\",\"receiver\":\"alicealice11\",\"quant\":\"1.0000 EOS\"}") 657 | .setData(new BuyRamDataEntity().setPayer("bobbobbobbob").setReceiver("alicealice11").setQuant("1.0000 EOS")); 658 | contractRequest.addAction(contractActionRequest); 659 | 660 | TransferAction transferActionRequest = new TransferAction(); 661 | transferActionRequest.setAccount("eosio.token") 662 | .setName("transfer") 663 | .setInfo("transfer to alicealice11") 664 | .setData(new TransferData().setFrom("bobbobbobbob").setTo("alicealice11").setQuantity("0.0001 EOS").setMemo("memo")); 665 | contractRequest.addAction(transferActionRequest); 666 | 667 | MYKEYSdk.getInstance().contract(contractRequest, new MYKEYWalletCallback() { 668 | @Override 669 | public void onSuccess(String dataJson) { 670 | // dataJson:{"txId":""} 671 | LogUtil.e(TAG, "onSuccess"); 672 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 673 | } 674 | 675 | @Override 676 | public void onError(String payloadJson) { 677 | // payloadJson: {"errorCode":,"errorMsg":""} 678 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 679 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 680 | } 681 | 682 | @Override 683 | public void onCancel() { 684 | LogUtil.e(TAG, "cancel"); 685 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 686 | } 687 | }); 688 | ``` 689 | 690 | ### sign 691 | 692 | Pull up MYKEY for Signature operation. See the class definition for the parameters: [SignRequest](mykey_android_sdk_en.md#class-signrequest) and [MYKEYWalletCallback](mykey_android_sdk_en.md#class-mykeywalletcallback) 693 | 694 | ```java 695 | SignRequest signRequest = new SignRequest().setMessage("Messages that need to be signed, [it could be random which come from dapp server]") 696 | // DApp CallbackUrl 697 | // param:{"protocol": "", "version": "", "message": "", "sign": "", "ref": "", "account": ""} 698 | // return: same as SimpleWallet {"code": [0-2], "message": ""} 699 | .setCallBackUrl(Config.DAPP_CALLBACK_URL); 700 | MYKEYSdk.getInstance().sign(signRequest, new MYKEYWalletCallback() { 701 | @Override 702 | public void onSuccess(String dataJson) { 703 | // dataJson:{"sign":""} 704 | LogUtil.e(TAG, "onSuccess data:" + dataJson); 705 | Toast.makeText(activity, "success", Toast.LENGTH_LONG).show(); 706 | } 707 | 708 | @Override 709 | public void onError(String payloadJson) { 710 | // payloadJson: {"errorCode":,"errorMsg":""} 711 | LogUtil.e(TAG, "onError payloadJson:" + payloadJson); 712 | Toast.makeText(activity, "error, payloadJson:" + payloadJson, Toast.LENGTH_LONG).show(); 713 | } 714 | 715 | @Override 716 | public void onCancel() { 717 | LogUtil.e(TAG, "cancel"); 718 | Toast.makeText(activity, "cancelled", Toast.LENGTH_LONG).show(); 719 | } 720 | }); 721 | ``` 722 | 723 | ### jumpToGuideInstall 724 | 725 | Jump to the pop-up to MYKEY installation page and boot when the user does not have MYKEY installed. 726 | 727 | ### Other Field Summary 728 | 729 | | Field | Type | Description | 730 | | :--- | :---: | :--- | 731 | | initHandle | com.mykey.sdk.handle.InitHandle | initialization implemented logic | 732 | | authorizeHandle | com.mykey.sdk.handle.AuthorizeHandle | Authorize implemented logic | 733 | | transferHandle | com.mykey.sdk.handle.TransferHandle | Transfer implemented logic | 734 | | contractHandle | com.mykey.sdk.handle.ContractHandle | Contract implemented logic | 735 | | signatureHandle | com.mykey.sdk.handle.SignatureHandle | Sign implemented logic | 736 | 737 | ## Other Class Defination 738 | 739 | ### Class InitRequest 740 | 741 | | properties | Type | Description | 742 | | :--- | :---: | :--- | 743 | | context | android.content.Context | dapp application context | 744 | | appKey | String | unique id assigned to each dapp, contact us | 745 | | userId | String | the unique user id in dapp server side, recommend to use uuid | 746 | | dappName | String | dapp name | 747 | | dappIcon | String | dapp icon logo, no small than 144x144px | 748 | | disableInstall\(default false\) | boolean | Whether to disable the default install page when MYKEY is not installed | 749 | | callback | String | Deeplink MYKEY callback to dapp,defined in [AndroidManifest.xml](mykey_android_sdk_en.md#5-copy-following-code-to-androidmanifestxml-and-set-the-callback-deeplink-composed-by-schemehost-and-path), e.g. customscheme://customhost/custompath | 750 | | showUpgradeTip\(default false\) | boolean | Toast tip when MYKEY is not the latest version | 751 | | mykeyServer | String | Environment URL endpoint of MYKEY server | 752 | 753 | ### Class InitSimpleRequest 754 | 755 | | properties | Type | Description | 756 | | :--- | :---: | :--- | 757 | | context | android.content.Context | dapp application context | 758 | | dappName | String | dapp name | 759 | | dappIcon | String | dapp icon logo, no small than 144x144px | 760 | | disableInstall\(default false\) | boolean | Whether to disable the default install page when MYKEY is not installed | 761 | | callback | String | Deeplink MYKEY callback to dapp,defined in [AndroidManifest.xml](mykey_android_sdk_en.md), e.g. customscheme://customhost/custompath | 762 | 763 | ### Class AuthorizeRequest 764 | 765 | | properties | Type | Description | 766 | | :--- | :---: | :--- | 767 | | userName | String | Custom user name | 768 | | callBackUrl\(optional\) | String | Optional, Callback endpoint url of dapp server,MYKEY will callback to dapp server after authorize request success at first, then wake up mobile client | 769 | | info | String | Info, Semantic description of MYKEY display to the user for authorization page | 770 | 771 | ### Class TransferRequest 772 | 773 | | properties | Type | Description | 774 | | :--- | :---: | :--- | 775 | | from | String | From account | 776 | | to | String | To account | 777 | | amount | String | Amount, e.g "1.0000" | 778 | | symbol | String | Symbol, e.g. "EOS" | 779 | | contractName | String | contract code name, e.g. "eosio.token" | 780 | | decimal | String | Decimal | 781 | | memo | String | Memo | 782 | | info | String | Semantic description of MYKEY display to the user about this action | 783 | | orderId | String | The order id from dapp, optional, can be null e.g. "20190606001" | 784 | | callbackUrl\(optional\) | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after transfer request success at first, then wake up mobile client | 785 | 786 | ### Class ContractRequest 787 | 788 | | properties | Type | Description | 789 | | :--- | :---: | :--- | 790 | | orderId | String | The order id from dapp, optional, can be null | 791 | | info | String | Semantic description of MYKEY display to the user about this action | 792 | | callbackUrl\(optional\) | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after contract request success at first, then wake up mobile client | 793 | | list\ | [ContractAction](mykey_android_sdk_en.md#class-contractaction) or [TransferAction](mykey_android_sdk_en.md#class-transferaction) | List of contract actions | 794 | 795 | ### Class ContractAction 796 | 797 | | properties | Type | Description | 798 | | :--- | :---: | :--- | 799 | | account | String | contract code name | 800 | | name | String | contract action name | 801 | | info | String | Semantic description of MYKEY display to the user about this action | 802 | | data | Object | The parameter object passed according to the contract abi definition e.g. {key1: value1, key2: value2 } | 803 | 804 | ### Class TransferAction 805 | 806 | | properties | Type | Description | 807 | | :--- | :---: | :--- | 808 | | account | String | contract code name | 809 | | name | String | contract action name, use "transfer" | 810 | | info | String | Semantic description of MYKEY display to the user about this action | 811 | | transferObj | [TransferData](mykey_android_sdk_en.md#class-transferdata) | Transfer info object | 812 | 813 | ### Class TransferData 814 | 815 | | properties | Type | Description | 816 | | :--- | :---: | :--- | 817 | | from | String | From account name | 818 | | to | String | To account name | 819 | | quantity | String | Amount and Symbol | 820 | | memo | String | Memo | 821 | 822 | ### Class SignRequest 823 | 824 | | properties | Type | Description | 825 | | :--- | :---: | :--- | 826 | | message | String | Unsigned messages | 827 | | callbackUrl | String | Optional, callback endpoint url of dapp server,MYKEY will callback to dapp server after sign request success at first, then wake up mobile client | 828 | 829 | ### Class MYKEYWalletCallback 830 | 831 | | methods | Description | 832 | | :--- | :--- | 833 | | onSuccess | Success Callback | 834 | | onError | Failure Callback,[errorCode list](mykey_android_sdk_en.md#error-code) | 835 | | onCancel | Cancel Callback | 836 | 837 | ## Error Code 838 | 839 | 0-2 are defined by SimpleWallet 840 | 841 | 10001-X are defined by MYKEYSdk 842 | 843 | | code | Description | 844 | | :--- | :--- | 845 | | 0 | User cancel the transaction | 846 | | 1 | Success | 847 | | 2 | Failure | 848 | | 10001 | unknow issue lead can not wakeup MYKEY | 849 | | 10002 | MYKEY not installed yet | 850 | | 10003 | MYKEY account is frozen | 851 | | 10004 | Uninitialized | 852 | | 10005 | Push transaction timeout | 853 | | 10006 | Binded, triggered at authorize | 854 | | 10007 | Unbind, triggered at transaction, trasnfer, sign | 855 | | 10008 | dapp binded, and MYKEY unbind, triggered at transaction, trasnfer, sign | 856 | | 10009 | MYKEY binded, triggered at authorize | 857 | | 10010 | dapp binded, and MYKEY binded, but not match | 858 | | 10011 | MYKEY unregistered, triggered at transaction, trasnfer, sign | 859 | | 10012 | Illegal param | 860 | | 10013 | Insufficient balance | 861 | | 10014 | MYKEY account unavailable | 862 | 863 | --------------------------------------------------------------------------------