├── Readme-zh.md └── Readme.md /Readme-zh.md: -------------------------------------------------------------------------------- 1 | # StandardEOSWallet 协议标准 2 | 3 | 版本:1.0.0 4 | 5 | 最后更新:20180817 6 | 7 | 支持平台:WEB端 8 | 9 | [English](https://github.com/EOSMore/StandardEOSWallet-DappProtocol/blob/master/Readme.md) 10 | 11 | ## 数据格式 12 | 13 | ### 二维码数据格式 14 | 15 | 采用`json`格式,字段如下: 16 | 17 | | 参数 | 类型 | 说明 | 18 | | :-------: | :-----: | :------------------------------------------------------: | 19 | | protocol | string | 协议名称,赋值为 StandardEOSWallet | 20 | | version | string | 协议版本号 | 21 | | action | string | 操作类型 | 22 | | action_id | string | 本次操作唯一ID | 23 | | expired | integer | 操作过期时间戳,单位秒 | 24 | | data | object | 操作参数 | 25 | | memo | string | 请求说明信息 | 26 | | callback | string | 操作回调接口链接 | 27 | | dapp | object | 包含两个参数:name 和 icon,分别为 dapp 名称和 logo 链接 | 28 | 29 | ### 回调接口公共请求参数 30 | 31 | > 调用所有回调接口都需要传这些参数 32 | 33 | | 参数 | 类型 | 说明 | 34 | | :-------: | :-----: | :--------------------------------: | 35 | | protocol | string | 协议名称,赋值为 StandardEOSWallet | 36 | | version | string | 协议版本号 | 37 | | action | string | 操作类型 | 38 | | action_id | string | 本次操作唯一ID | 39 | | account | string | 操作eos账号 | 40 | | timestamp | integer | 操作时间戳,单位秒 | 41 | | source | string | 来源钱包名称,如MoreWallet | 42 | | sign | string | 通用签名 | 43 | 44 | ### 回调接口返回参数 45 | 46 | | 参数 | 类型 | 说明 | 47 | | :-----: | :-----: | :---------------------------: | 48 | | code | integer | code=0表示成功 其他值表示失败 | 49 | | message | string | 错误信息 | 50 | 51 | ## 登录 52 | 53 | ### 二维码数据示例 54 | 55 | ```json 56 | { 57 | "protocol": "StandardEOSWallet", 58 | "version": "1.0.0", 59 | "action": "login", 60 | "action_id": "xxxxxx", 61 | "expired": 1534347099, 62 | "data": {}, 63 | "memo": "这是一款xxx的eos dapp", 64 | "callback": "https://api.dappdemo.com/login", 65 | "dapp": { 66 | "name": "Southex", 67 | "icon": "http://swdemo.southex.com/static/southex.png" 68 | } 69 | } 70 | ``` 71 | 72 | ### 签名 73 | 74 | ```javascript 75 | // 生成sign算法 76 | let data = timestamp + account + action_id + source // source为钱包名,标示来源 77 | sign = ecc.sign(data, privateKey) 78 | ``` 79 | 80 | ### 回调接口请求参数 81 | 82 | | 参数 | 类型 | 说明 | 83 | | :--: | :----: | :--------------: | 84 | | sign | string | 上一步获取的签名 | 85 | 86 | ## 转账 87 | 88 | ### 二维码数据示例 89 | 90 | ```json 91 | { 92 | "protocol": "StandardEOSWallet", 93 | "version": "1.0.0", 94 | "action": "transfer", 95 | "action_id": "xxxxxx", 96 | "expired": 1534347099, 97 | "data": { 98 | "contract": "eosio.token", 99 | "from": "loginaccount", 100 | "to": "transferto22", 101 | "quantity": "10.0000 EOS", 102 | "memo": "转账备注" 103 | }, 104 | "memo": "用于租赁cpu", 105 | "callback": "https://api.dappdemo.com/transfer/callback", 106 | "dapp": { 107 | "name": "Southex", 108 | "icon": "http://swdemo.southex.com/static/southex.png" 109 | } 110 | } 111 | ``` 112 | 113 | ### 回调接口请求参数 114 | 115 | | 参数 | 类型 | 说明 | 116 | | :------------: | :----: | :----: | 117 | | transaction_id | string | 交易ID | 118 | 119 | ## 提交transaction 120 | 121 | ### 二维码数据示例 122 | 123 | ```json 124 | { 125 | "protocol": "StandardEOSWallet", 126 | "version": "1.0.0", 127 | "action": "push_transaction", 128 | "action_id": "xxxxxx", 129 | "expired": 1534347099, 130 | "data": { 131 | "actions": [{ 132 | "account": "eosio", 133 | "name": "buyram", 134 | "authorization": [{ 135 | "actor": "demouser1111", 136 | "permission": "active" 137 | }], 138 | "data": { 139 | "payer": "demouser1111", 140 | "receiver": "demouser1111", 141 | "quant": "10.0000 EOS" 142 | } 143 | }, { 144 | "account": "eosio", 145 | "name": "delegatebw", 146 | "authorization": [{ 147 | "actor": "demouser1111", 148 | "permission": "active" 149 | }], 150 | "data": { 151 | "from": "demouser1111", 152 | "receiver": "demouser1111", 153 | "stake_net_quantity": "10.0000 EOS", 154 | "stake_cpu_quantity": "5.0000 EOS", 155 | "transfer": false 156 | } 157 | }] 158 | }, 159 | "memo": "", 160 | "callback": "https://api.dappdemo.com/push_transaction/callback", 161 | "dapp": { 162 | "name": "Southex", 163 | "icon": "http://swdemo.southex.com/static/southex.png" 164 | } 165 | } 166 | ``` 167 | 168 | ### 回调接口请求参数 169 | 170 | | 参数 | 类型 | 说明 | 171 | | :------------: | :----: | :----: | 172 | | transaction_id | string | 交易ID | 173 | 174 | ## 分页 175 | 176 | ### 当二维码内容过长时, 分页示例 177 | 178 | **当存在多个Actions可能会因为json内容过长导致二维码无法识别, 建议使用分页模式, 具体则是通过在字段data中设置pageable的为总页数, APP识别到pageable的存在则会进入连续扫码模式, 分页内容应如下设计** 179 | 180 | 181 | **检测到pageble开启连续扫码模式, 并根据action_id判断接下来的扫码内容是否为当前连续扫码模式** 182 | ```json 183 | { 184 | "protocol": "StandardEOSWallet", 185 | "version": "1.0.0", 186 | "action": "push_transaction", 187 | "action_id": "xxxxxx", 188 | "expired": 1534347099, 189 | "data": 190 | { 191 | "pageable": 2 192 | }, 193 | "memo": "", 194 | "callback": "https://api.dappdemo.com/push_transaction/callback", 195 | "dapp": 196 | { 197 | "name": "Southex", 198 | "icon": "http://swdemo.southex.com/static/southex.png" 199 | } 200 | } 201 | ``` 202 | 203 | **根据action_id判断是属于当前连续模式下内容, 并通过page字段来覆盖相同内容的重复扫描** 204 | ```json 205 | 206 | { 207 | "action_id": "xxxxxx", 208 | "data": 209 | { 210 | "page": 1, 211 | "actions": [ 212 | { 213 | "account": "eosio", 214 | "name": "buyram", 215 | "authorization": [ 216 | { 217 | "actor": "demouser1111", 218 | "permission": "active" 219 | }], 220 | "data": 221 | { 222 | "payer": "demouser1111", 223 | "receiver": "demouser1111", 224 | "quant": "10.0000 EOS" 225 | } 226 | }] 227 | } 228 | } 229 | ``` 230 | 231 | **连续扫码每次结束后判断当前存储的actions lenght是否等于pageable, 若是则结束扫码** 232 | ```json 233 | { 234 | "action_id": "xxxxxx", 235 | "data": 236 | { 237 | "page": 2, 238 | "actions": [ 239 | { 240 | "account": "eosio", 241 | "name": "delegatebw", 242 | "authorization": [{ 243 | "actor": "demouser1111", 244 | "permission": "active" 245 | }], 246 | "data": { 247 | "from": "demouser1111", 248 | "receiver": "demouser1111", 249 | "stake_net_quantity": "10.0000 EOS", 250 | "stake_cpu_quantity": "5.0000 EOS", 251 | "transfer": false 252 | } 253 | }] 254 | } 255 | } 256 | ``` 257 | 258 | ***若在连续扫码模式下, 扫描到不存在action_id或action_id不相同的内容, 建议退出连续扫码模式, 重新识别内容*** 259 | 260 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # StandardEOSWallet Protocol Standard 2 | 3 | Version:1.0.0 4 | 5 | Latest Update:20180817 6 | 7 | Support Platform:WEB 8 | 9 | [中文版](https://github.com/EOSMore/StandardEOSWallet-DappProtocol/blob/master/Readme-zh.md) 10 | 11 | ## Date Format 12 | 13 | ### QR Code Format 14 | 15 | Use `json` format,field as below: 16 | 17 | | Data | Type | State | 18 | | :-------: | :-----: | :----------------------------------------------------------: | 19 | | protocol | string | protocol name, assignment is StandardEOSWallet | 20 | | version | string | protocol version number | 21 | | action | string | action type | 22 | | action_id | string | specific ID of current action | 23 | | expired | integer | action expired timestamp, unit is second | 24 | | data | object | action data | 25 | | memo | string | request memo information | 26 | | callback | string | action callback integrate link | 27 | | dapp | object | includes two data:name and icon,they are dapp name and logo link | 28 | 29 | ### Callback Integrate Public Request Data 30 | 31 | > All Data requested for calling all callback integration 32 | 33 | | Data | Type | State | 34 | | :-------: | :-----: | :--------------------------------: | 35 | | protocol | string | protocol name, assignment is StandardEOSWallet | 36 | | version | string | protocol version number | 37 | | action | string | action type | 38 | | action_id | string | specific ID of current action | 39 | | account | string | action eos account | 40 | | timestamp | integer | action timestamp, unit is second | 41 | | source | string | name of source wallet,such as MoreWallet | 42 | | sign | string | generic sign | 43 | 44 | ### Callback Interface Return Data 45 | 46 | | Data | Type | State | 47 | | :-----: | :-----: | :---------------------------------------------: | 48 | | code | integer | code=0 means success, other values mean failure | 49 | | message | string | error message | 50 | 51 | ## Login 52 | 53 | ### QR Code Data Example 54 | 55 | ```json 56 | { 57 | "protocol": "StandardEOSWallet", 58 | "version": "1.0.0", 59 | "action": "login", 60 | "action_id": "xxxxxx", 61 | "expired": 1534347099, 62 | "data": {}, 63 | "memo": "This is a xxx eos dapp", 64 | "callback": "https://api.dappdemo.com/login", 65 | "dapp": { 66 | "name": "Southex", 67 | "icon": "http://swdemo.southex.com/static/southex.png" 68 | } 69 | } 70 | ``` 71 | 72 | ### Sign 73 | 74 | ```javascript 75 | // generate sign algorithm 76 | let data = timestamp + account + action_id + source // source is wallet name, indicate the source 77 | sign = ecc.sign(data, privateKey) 78 | ``` 79 | 80 | ### Callback Interface Request Data 81 | 82 | | Data | Type | State | 83 | | :--: | :----: | :-----------------------------: | 84 | | sign | string | Sign accquired in previous step | 85 | 86 | ## Transfer 87 | 88 | ### QR Code Data Example 89 | 90 | ```json 91 | { 92 | "protocol": "StandardEOSWallet", 93 | "version": "1.0.0", 94 | "action": "transfer", 95 | "action_id": "xxxxxx", 96 | "expired": 1534347099, 97 | "data": { 98 | "contract": "eosio.token", 99 | "from": "loginaccount", 100 | "to": "transferto22", 101 | "quantity": "10.0000 EOS", 102 | "memo": "transfer remark" 103 | }, 104 | "memo": "use for renting cpu", 105 | "callback": "https://api.dappdemo.com/transfer/callback", 106 | "dapp": { 107 | "name": "Southex", 108 | "icon": "http://swdemo.southex.com/static/southex.png" 109 | } 110 | } 111 | ``` 112 | 113 | ### Callback Interface Request Data 114 | 115 | | Data | Type | State | 116 | | :------------: | :----: | :------------: | 117 | | transaction_id | string | transaction ID | 118 | 119 | ## Submit Transaction 120 | 121 | ### QR Code Data Example 122 | 123 | ```json 124 | { 125 | "protocol": "StandardEOSWallet", 126 | "version": "1.0.0", 127 | "action": "push_transaction", 128 | "action_id": "xxxxxx", 129 | "expired": 1534347099, 130 | "data": { 131 | "actions": [{ 132 | "account": "eosio", 133 | "name": "buyram", 134 | "authorization": [{ 135 | "actor": "demouser1111", 136 | "permission": "active" 137 | }], 138 | "data": { 139 | "payer": "demouser1111", 140 | "receiver": "demouser1111", 141 | "quant": "10.0000 EOS" 142 | } 143 | }, { 144 | "account": "eosio", 145 | "name": "delegatebw", 146 | "authorization": [{ 147 | "actor": "demouser1111", 148 | "permission": "active" 149 | }], 150 | "data": { 151 | "from": "demouser1111", 152 | "receiver": "demouser1111", 153 | "stake_net_quantity": "10.0000 EOS", 154 | "stake_cpu_quantity": "5.0000 EOS", 155 | "transfer": false 156 | } 157 | }] 158 | }, 159 | "memo": "", 160 | "callback": "https://api.dappdemo.com/push_transaction/callback", 161 | "dapp": { 162 | "name": "Southex", 163 | "icon": "http://swdemo.southex.com/static/southex.png" 164 | } 165 | } 166 | ``` 167 | 168 | ### Callback Interface Request Data 169 | 170 | | Data | Type | State | 171 | | :------------: | :----: | :------------: | 172 | | transaction_id | string | Transaction ID | 173 | 174 | ## Paging 175 | 176 | ### Paging example when QR code content overlong 177 | 178 | **Overlong json content will lead to the QR code unidentified when several Actions existed. Details will be setting pageable as total pages in field data, APP will enter continuous scanning mode when identified pageable existed, paging content should be designed as below** 179 | 180 | **Open continuous scanning mode when identified pageable, and estimate if following scan content belong to continuous scanning mode account to action_id** 181 | 182 | ```json 183 | { 184 | "protocol": "StandardEOSWallet", 185 | "version": "1.0.0", 186 | "action": "push_transaction", 187 | "action_id": "xxxxxx", 188 | "expired": 1534347099, 189 | "data": 190 | { 191 | "pageable": 2 192 | }, 193 | "memo": "", 194 | "callback": "https://api.dappdemo.com/push_transaction/callback", 195 | "dapp": 196 | { 197 | "name": "Southex", 198 | "icon": "http://swdemo.southex.com/static/southex.png" 199 | } 200 | } 201 | ``` 202 | 203 | **Estimate if the content belongs to current continuous scanning mode according to actioin_id, and cover same content repeat scanning by page field** 204 | 205 | ```json 206 | 207 | { 208 | "action_id": "xxxxxx", 209 | "data": 210 | { 211 | "page": 1, 212 | "actions": [ 213 | { 214 | "account": "eosio", 215 | "name": "buyram", 216 | "authorization": [ 217 | { 218 | "actor": "demouser1111", 219 | "permission": "active" 220 | }], 221 | "data": 222 | { 223 | "payer": "demouser1111", 224 | "receiver": "demouser1111", 225 | "quant": "10.0000 EOS" 226 | } 227 | }] 228 | } 229 | } 230 | ``` 231 | 232 | **Continuous scanning will estimate if current stored actions length equal to pageable every ended, stop scanning if yes** 233 | 234 | ```json 235 | { 236 | "action_id": "xxxxxx", 237 | "data": 238 | { 239 | "page": 2, 240 | "actions": [ 241 | { 242 | "account": "eosio", 243 | "name": "delegatebw", 244 | "authorization": [{ 245 | "actor": "demouser1111", 246 | "permission": "active" 247 | }], 248 | "data": { 249 | "from": "demouser1111", 250 | "receiver": "demouser1111", 251 | "stake_net_quantity": "10.0000 EOS", 252 | "stake_cpu_quantity": "5.0000 EOS", 253 | "transfer": false 254 | } 255 | }] 256 | } 257 | } 258 | ``` 259 | 260 | 261 | ***If nonexistent or different action_id content scanned under continuous scanning mode, suggest to quit the continuous scanning mode first and identify again*** --------------------------------------------------------------------------------