You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872
  1. ### 交易
  2. ```bash
  3. :bin$ ./jdchain-cli.sh tx -h
  4. Usage: jdchain-cli tx [-hV] [--pretty] [--export=<export>] [--gw-host=<gwHost>]
  5. [--gw-port=<gwPort>] [--home=<path>] [COMMAND]
  6. Build, sign or send transaction.
  7. --export=<export> Transaction export directory
  8. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  9. Default: 127.0.0.1
  10. --gw-port=<gwPort> Set the gateway port. Default: 8080
  11. Default: 8080
  12. -h, --help Show this help message and exit.
  13. --home=<path> Set the home directory.
  14. Default: ../
  15. --pretty Pretty json print
  16. -V, --version Print version information and exit.
  17. Commands:
  18. root-ca Update ledger root certificates.
  19. user-register Register new user.
  20. user-ca Update user certificate.
  21. user-state Update user(certificate) state.
  22. role Create or config role.
  23. authorization User role authorization.
  24. data-account-register Register new data account.
  25. data-account-permission Update data account permission.
  26. kv Set key-value.
  27. event-account-register Register event account.
  28. event-account-permission Update event account permission.
  29. event Publish event.
  30. event-listen Subscribe event.
  31. contract-deploy Deploy or update contract.
  32. contract-permission Update contract permission.
  33. contract Call contract method.
  34. contract-state Update contract state.
  35. sign Sign transaction.
  36. send Send transaction.
  37. help Displays help information about the specified
  38. command
  39. ```
  40. 参数:
  41. - `export`,导出交易到指定位置,用于离线交易相关命令
  42. - `gw-host`,网关服务地址,默认`127.0.0.1`
  43. - `gw-port`,网关服务端口,默认`8080`
  44. - `home`,指定密钥存储相关目录,`${home}/config/keys`
  45. 命令:
  46. - `root-ca`,[更新账本根证书](#更新账本根证书)
  47. - `user-register`,[注册用户](#注册用户)
  48. - `user-ca`,[更新用户证书](#更新用户证书)
  49. - `user-state`,[更新用户(证书)状态](#更新用户(证书)状态)
  50. - `role`,[角色管理](#角色管理)
  51. - `authorization`,[权限配置](#权限配置)
  52. - `data-account-register`,[注册数据账户](#注册数据账户)
  53. - `data-account-permission`,[修改数据账户权限](#修改数据账户权限)
  54. - `kv`,[KV设值](#KV设值)
  55. - `event-account-register`,[注册事件账户](#注册事件账户)
  56. - `event-account-permission`,[修改事件账户权限](#修改事件账户权限)
  57. - `event`,[发布事件](#发布事件)
  58. - `event-listen`,[监听事件](#监听事件)
  59. - `contract-deploy`,[部署合约](#部署合约)
  60. - `contract-permission`,[修改合约权限](#修改合约权限)
  61. - `contract`,[合约调用](#合约调用)
  62. - `contract-state`,[更新合约状态](#更新合约状态)
  63. - `sign`,[离线交易签名](#离线交易签名)
  64. - `send`,[离线交易发送](#离线交易发送)
  65. #### 更新账本根证书
  66. ```bash
  67. :bin$ ./jdchain-cli.sh tx root-ca -h
  68. Update ledger root certificates.
  69. Usage: jdchain-cli tx ledger-ca-update [-hV] [--pretty] --crt=<caPath>
  70. [--export=<export>] [--gw-host=<gwHost>]
  71. [--gw-port=<gwPort>] [--home=<path>]
  72. --crt=<caPath> File of the X509 certificate
  73. --operation Operation for this certificate. Optional values: ADD,UPDATE,REMOVE
  74. --export=<export> Transaction export directory
  75. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  76. --gw-port=<gwPort> Set the gateway port. Default: 8080
  77. -h, --help Show this help message and exit.
  78. --home=<path> Set the home directory.
  79. --pretty Pretty json print
  80. -V, --version Print version information and exit.
  81. ```
  82. - `crt`,证书文件路径
  83. - `operation`,操作类型:`ADD`,`UPDATE`,`REMOVE`
  84. 如:
  85. ```bash
  86. :bin$ $ ./jdchain-cli.sh tx root-ca --crt /home/imuge/jd/nodes/peer0/config/keys/ledger.crt --operation UPDATE
  87. select ledger, input the index:
  88. INDEX LEDGER
  89. 0 j5pFrMigE47t6TobQJXsztnoeA29H31v1vHHF1wqCp4rzi
  90. // 选择账本,当前网关服务只有上面一个可用账本
  91. > 0
  92. select keypair to sign tx:
  93. INDEX KEY ADDRESS
  94. 0 peer0 LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W
  95. // 选择链上已存在且有注册用户权限的用户所对应的公私钥对,用于交易签名
  96. > 0
  97. input password of the key:
  98. // 输入签名私钥密码
  99. > 1
  100. ledger ca: [7VeRBQ9jpsgNXje2NYXU5MhyGKVRj462RtkJ8f6FNL1oxYbX](pubkey) updated
  101. ```
  102. 会更新链上公钥为`7VeRBQ9jpsgNXje2NYXU5MhyGKVRj462RtkJ8f6FNL1oxYbX`的账本证书信息。
  103. #### 注册用户
  104. ```bash
  105. :bin$ ./jdchain-cli.sh tx user-register -h
  106. Register new user.
  107. Usage: jdchain-cli tx user-register [-hV] [--ca-mode] [--pretty]
  108. [--crt=<caPath>] [--export=<export>]
  109. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  110. [--home=<path>] [-n=<name>]
  111. [--pubkey=<pubkey>]
  112. --ca-mode Register with CA
  113. --crt=<caPath> File of the X509 certificate
  114. --export=<export> Transaction export directory
  115. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  116. --gw-port=<gwPort> Set the gateway port. Default: 8080
  117. -h, --help Show this help message and exit.
  118. --home=<path> Set the home directory.
  119. -n, --name=<name> Name of the key
  120. --pretty Pretty json print
  121. --pubkey=<pubkey> Pubkey of the user
  122. -V, --version Print version information and exit.
  123. ```
  124. - `ca-mode`,身份认证模式是否为证书(`CA`)模式,默认`false`
  125. - `name`,当`ca-mode`为`true`时会读取本地`${home}/config/keys/${name}.crt`文件,反之读取`${home}/config/keys/${name}.pub`
  126. - `crt`,证书文件路径
  127. - `pubkey`,`Base58`编码公钥信息,仅在非`ca-mode`情况下使用
  128. 从`${home}/config/keys`目录下密钥对选择密钥注册到网关服务对应的区块链网络。
  129. 如:
  130. ```bash
  131. :bin$ ./jdchain-cli.sh tx user-register -name k1
  132. select ledger, input the index:
  133. INDEX LEDGER
  134. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  135. // 选择账本,当前网关服务只有上面一个可用账本
  136. > 0
  137. select keypair to sign tx:
  138. INDEX KEY ADDRESS
  139. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  140. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  141. // 选择链上已存在且有注册用户权限的用户所对应的公私钥对,用于交易签名
  142. > 0
  143. input password of the key:
  144. // 输入签名私钥密码
  145. > 1
  146. register user: [LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC]
  147. ```
  148. 会在链上注册地址为`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`的用户账户信息。
  149. #### 更新用户证书
  150. ```bash
  151. :bin$ ./jdchain-cli.sh tx user-ca -h
  152. Update user certificate.
  153. Usage: jdchain-cli tx user-ca [-hV] [--pretty] [--crt=<caPath>]
  154. [--export=<export>] [--gw-host=<gwHost>]
  155. [--gw-port=<gwPort>] [--home=<path>]
  156. --crt=<caPath> File of the X509 certificate
  157. --export=<export> Transaction export directory
  158. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  159. --gw-port=<gwPort> Set the gateway port. Default: 8080
  160. -h, --help Show this help message and exit.
  161. --home=<path> Set the home directory.
  162. --pretty Pretty json print
  163. -V, --version Print version information and exit.
  164. ```
  165. - `crt`,证书文件路径
  166. 如:
  167. ```bash
  168. :bin$ $ ./jdchain-cli.sh tx user-ca --crt /home/imuge/jd/nodes/peer0/config/keys/peer0.crt
  169. select ledger, input the index:
  170. INDEX LEDGER
  171. 0 j5pFrMigE47t6TobQJXsztnoeA29H31v1vHHF1wqCp4rzi
  172. // 选择账本,当前网关服务只有上面一个可用账本
  173. > 0
  174. select keypair to sign tx:
  175. INDEX KEY ADDRESS
  176. 0 peer0 LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W
  177. // 选择链上已存在且有注册用户权限的用户所对应的公私钥对,用于交易签名
  178. > 0
  179. input password of the key:
  180. // 输入签名私钥密码
  181. > 1
  182. user: [LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W] ca updated
  183. ```
  184. 会更新链上地址为`LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W`的用户证书信息。
  185. #### 更新用户(证书)状态
  186. ```bash
  187. :bin$ ./jdchain-cli.sh tx user-state -h
  188. Update user(certificate) state.
  189. Usage: jdchain-cli tx user-state [-hV] [--pretty] --address=<address>
  190. [--export=<export>]
  191. [--gw-host=<gwHost>]
  192. [--gw-port=<gwPort>] [--home=<path>]
  193. --state=<state>
  194. --address=<address> User address
  195. --export=<export> Transaction export directory
  196. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  197. --gw-port=<gwPort> Set the gateway port. Default: 8080
  198. -h, --help Show this help message and exit.
  199. --home=<path> Set the home directory.
  200. --pretty Pretty json print
  201. --state=<state> User state,Optional values: FREEZE,NORMAL,REVOKE
  202. -V, --version Print version information and exit.
  203. ```
  204. - `address`,用户地址
  205. - `state`,用户状态,可选值:FREEZE,NORMAL,REVOKE
  206. 如冻结用户`LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W`:
  207. ```bash
  208. :bin$ $ ./jdchain-cli.sh tx user-state --address LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W --state FREEZE
  209. select ledger, input the index:
  210. INDEX LEDGER
  211. 0 j5pFrMigE47t6TobQJXsztnoeA29H31v1vHHF1wqCp4rzi
  212. // 选择账本,当前网关服务只有上面一个可用账本
  213. > 0
  214. select keypair to sign tx:
  215. INDEX KEY ADDRESS
  216. 0 peer0 LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W
  217. // 选择链上已存在且有注册用户权限的用户所对应的公私钥对,用于交易签名
  218. > 0
  219. input password of the key:
  220. // 输入签名私钥密码
  221. > 1
  222. user: [LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W] revoked
  223. ```
  224. 会冻结链上地址为`LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W`的用户(证书),此用户无法再接入使用此网络。
  225. #### 角色管理
  226. ```bash
  227. :bin$ ./jdchain-cli.sh tx role -h
  228. Create or config role.
  229. Usage: jdchain-cli tx role [-hV] [--pretty] [--export=<export>]
  230. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  231. [--home=<path>] --name=<role>
  232. [--disable-ledger-perms=<disableLedgerPerms>[,
  233. <disableLedgerPerms>...]]...
  234. [--disable-transaction-perms=<disableTransactionPerms
  235. >[,<disableTransactionPerms>...]]...
  236. [--enable-ledger-perms=<enableLedgerPerms>[,
  237. <enableLedgerPerms>...]]...
  238. [--enable-transaction-perms=<enableTransactionPerms>
  239. [,<enableTransactionPerms>...]]...
  240. --disable-ledger-perms=<disableLedgerPerms>[,<disableLedgerPerms>...]
  241. Disable ledger permissions
  242. --disable-transaction-perms=<disableTransactionPerms>[,
  243. <disableTransactionPerms>...]
  244. Disable transaction permissions
  245. --enable-ledger-perms=<enableLedgerPerms>[,<enableLedgerPerms>...]
  246. Enable ledger permissions
  247. --enable-transaction-perms=<enableTransactionPerms>[,
  248. <enableTransactionPerms>...]
  249. Enable transaction permissions
  250. --export=<export> Transaction export directory
  251. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  252. --gw-port=<gwPort> Set the gateway port. Default: 8080
  253. -h, --help Show this help message and exit.
  254. --home=<path> Set the home directory.
  255. --name=<role> Role name
  256. --pretty Pretty json print
  257. -V, --version Print version information and exit.
  258. ```
  259. - `name`,角色名称,不存在则创建
  260. - `disable-ledger-perms`,禁用的账本权限列表,半角逗号分割
  261. - `disable-transaction-perms`,禁用的交易权限列表,半角逗号分割
  262. - `enable-ledger-perms`,的账本权限列表,半角逗号分割
  263. - `enable-transaction-perms`,禁用的交易权限列表,半角逗号分割
  264. 如:
  265. ```bash
  266. :bin$ ./jdchain-cli.sh tx role --name ROLE1 --enable-ledger-perms REGISTER_USER,REGISTER_DATA_ACCOUNT --enable-transaction-perms DIRECT_OPERATION,CONTRACT_OPERATION
  267. select ledger, input the index:
  268. INDEX LEDGER
  269. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  270. // 选择账本
  271. > 0
  272. select keypair to sign tx:
  273. INDEX KEY ADDRESS
  274. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  275. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  276. // 选择签名账户
  277. > 0
  278. input password of the key:
  279. // 输入签名账户私钥密码
  280. > 1
  281. Role config success!
  282. ```
  283. #### 权限配置
  284. ```bash
  285. :bin$ ./jdchain-cli.sh tx authorization -h
  286. User role authorization.
  287. Usage: jdchain-cli tx authorization [-hV] [--pretty] --address=<address>
  288. [--export=<export>] [--gw-host=<gwHost>]
  289. [--gw-port=<gwPort>] [--home=<path>]
  290. [--policy=<policy>]
  291. [--authorize=<authorizeRoles>[,
  292. <authorizeRoles>...]]...
  293. [--unauthorize=<unauthorizeRoles>[,
  294. <unauthorizeRoles>...]]...
  295. --address=<address> User address
  296. --authorize=<authorizeRoles>[,<authorizeRoles>...]
  297. Authorize roles
  298. --export=<export> Transaction export directory
  299. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  300. --gw-port=<gwPort> Set the gateway port. Default: 8080
  301. -h, --help Show this help message and exit.
  302. --home=<path> Set the home directory.
  303. --policy=<policy> Role policy
  304. --pretty Pretty json print
  305. --unauthorize=<unauthorizeRoles>[,<unauthorizeRoles>...]
  306. Unauthorize roles
  307. -V, --version Print version information and exit.
  308. ```
  309. - `address`,用户地址
  310. - `authorize`,赋予角色列表,半角逗号分割
  311. - `unauthorize`,移除角色列表,半角逗号分割
  312. - `policy`,角色策略,`UNION`/`INTERSECT`,默认`UNION`合并所有角色权限
  313. 如:
  314. ```bash
  315. :bin$ ./jdchain-cli.sh tx authorization --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --authorize ROLE1
  316. select ledger, input the index:
  317. INDEX LEDGER
  318. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  319. > 0
  320. select keypair to sign tx:
  321. INDEX KEY ADDRESS
  322. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  323. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  324. > 0
  325. input password of the key:
  326. > 1
  327. Authorization config success!
  328. ```
  329. #### 注册数据账户
  330. ```bash
  331. :bin$ ./jdchain-cli.sh tx data-account-register -h
  332. Register new data account.
  333. Usage: jdchain-cli tx data-account-register [-hV] [--pretty]
  334. [--export=<export>] [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  335. [--home=<path>] [--pubkey=<pubkey>]
  336. --export=<export> Transaction export directory
  337. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  338. --gw-port=<gwPort> Set the gateway port. Default: 8080
  339. -h, --help Show this help message and exit.
  340. --home=<path> Set the home directory.
  341. --pretty Pretty json print
  342. --pubkey=<pubkey> The pubkey of the exist data account
  343. -V, --version Print version information and exit.
  344. ```
  345. - `pubkey`,待注册数据账户公钥
  346. 如:
  347. ```bash
  348. :bin$ ./jdchain-cli.sh tx data-account-register --pubkey 7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk
  349. select ledger, input the index:
  350. INDEX LEDGER
  351. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  352. > 0
  353. select keypair to sign tx:
  354. INDEX KEY ADDRESS
  355. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  356. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  357. > 0
  358. input password of the key:
  359. > 1
  360. register data account: [LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC]
  361. ```
  362. 会在链上注册地址为`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`的数据账户信息。
  363. #### 修改数据账户权限
  364. ```bash
  365. :bin$ ./jdchain-cli.sh tx data-account-permission -h
  366. Update data account permission.
  367. Usage: jdchain-cli tx data-account-permission [-hV] [--pretty]
  368. [--address=<address>] [--export=<export>] [--gw-host=<gwHost>]
  369. [--gw-port=<gwPort>] [--home=<path>] [--mode=<mode>] [--role=<role>]
  370. --address=<address> Address of the data account
  371. --export=<export> Transaction export directory
  372. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  373. --gw-port=<gwPort> Set the gateway port. Default: 8080
  374. -h, --help Show this help message and exit.
  375. --home=<path> Set the home directory.
  376. --mode=<mode> Mode value of the data account
  377. --pretty Pretty json print
  378. --role=<role> Role of the data account
  379. -V, --version Print version information and exit.
  380. ```
  381. - `address`,数据账户地址
  382. - `role`,数据账户所属角色
  383. - `mode`,数据账户权限值
  384. 如:
  385. ```bash
  386. :bin$ ./jdchain-cli.sh tx data-account-permission --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --role ROLE1 --mode 777
  387. select ledger, input the index:
  388. INDEX LEDGER
  389. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  390. > 0
  391. select keypair to sign tx:
  392. INDEX KEY ADDRESS
  393. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  394. > 0
  395. input password of the key:
  396. > 1
  397. update data account: [LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC] permission
  398. ```
  399. 将修改数据账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`所属角色为`ROLE1`,权限值为`777`(所有用户可读可写)。
  400. #### KV设值
  401. ```bash
  402. :bin$ ./jdchain-cli.sh tx kv -h
  403. Set key-value.
  404. Usage: jdchain-cli tx kv [-hV] [--pretty] --address=<address>
  405. [--export=<export>] [--gw-host=<gwHost>]
  406. [--gw-port=<gwPort>] [--home=<path>] --key=<key>
  407. --value=<value> [--ver=<version>]
  408. --address=<address> Data account address
  409. --export=<export> Transaction export directory
  410. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  411. --gw-port=<gwPort> Set the gateway port. Default: 8080
  412. -h, --help Show this help message and exit.
  413. --home=<path> Set the home directory.
  414. --key=<key> Key to set
  415. --pretty Pretty json print
  416. -V, --version Print version information and exit.
  417. --value=<value> Value to set
  418. --ver=<version> Version of the key-value
  419. ```
  420. - `address`,数据账户地址
  421. - `key`,键
  422. - `value`,值
  423. - `ver`,版本
  424. 如向账户地址`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`写入`k1`:`v1`:`-1`键值对数据:
  425. ```bash
  426. :bin$ ./jdchain-cli.sh tx kv --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --key k1 --value v1 --ver -1
  427. select ledger, input the index:
  428. INDEX LEDGER
  429. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  430. > 0
  431. select keypair to sign tx:
  432. INDEX KEY ADDRESS
  433. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  434. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  435. > 0
  436. input password of the key:
  437. > 1
  438. set kv success
  439. ```
  440. #### 注册事件账户
  441. ```bash
  442. :bin$ ./jdchain-cli.sh tx event-account-register -h
  443. Register event account.
  444. Usage: jdchain-cli tx event-account-register [-hV] [--pretty]
  445. [--export=<export>] [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  446. [--home=<path>] [--pubkey=<pubkey>]
  447. --export=<export> Transaction export directory
  448. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  449. --gw-port=<gwPort> Set the gateway port. Default: 8080
  450. -h, --help Show this help message and exit.
  451. --home=<path> Set the home directory.
  452. --pretty Pretty json print
  453. --pubkey=<pubkey> The pubkey of the exist event account
  454. -V, --version Print version information and exit.
  455. ```
  456. - `pubkey`,待注册事件账户私钥
  457. 如:
  458. ```bash
  459. :bin$ ./jdchain-cli.sh tx event-account-register --pubkey 7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk
  460. select ledger, input the index:
  461. INDEX LEDGER
  462. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  463. > 0
  464. select keypair to sign tx:
  465. INDEX KEY ADDRESS
  466. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  467. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  468. > 0
  469. input password of the key:
  470. > 1
  471. register event account: [LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC]
  472. ```
  473. 会在链上注册地址为`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`的事件账户信息。
  474. #### 修改事件账户权限
  475. ```bash
  476. :bin$ ./jdchain-cli.sh tx event-account-permission -h
  477. Update event account permission.
  478. Usage: jdchain-cli tx event-account-permission [-hV] [--pretty]
  479. [--address=<address>] [--export=<export>] [--gw-host=<gwHost>]
  480. [--gw-port=<gwPort>] [--home=<path>] [--mode=<mode>] [--role=<role>]
  481. --address=<address> Address of the event account
  482. --export=<export> Transaction export directory
  483. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  484. --gw-port=<gwPort> Set the gateway port. Default: 8080
  485. -h, --help Show this help message and exit.
  486. --home=<path> Set the home directory.
  487. --mode=<mode> Mode value of the event account
  488. --pretty Pretty json print
  489. --role=<role> Role of the event account
  490. -V, --version Print version information and exit.
  491. ```
  492. - `address`,事件账户地址
  493. - `role`,事件账户所属角色
  494. - `mode`,事件账户权限值
  495. 如:
  496. ```bash
  497. :bin$ ./jdchain-cli.sh tx event-account-permission --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --role ROLE1 --mode 777
  498. select ledger, input the index:
  499. INDEX LEDGER
  500. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  501. > 0
  502. select keypair to sign tx:
  503. INDEX KEY ADDRESS
  504. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  505. > 0
  506. input password of the key:
  507. > 1
  508. update event account: [LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC] permission
  509. ```
  510. 将修改事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`所属角色为`ROLE1`,权限值为`777`(所有用户可读可写)。
  511. #### 发布事件
  512. ```bash
  513. :bin$ ./jdchain-cli.sh tx event -h
  514. Publish event.
  515. Usage: jdchain-cli tx event [-hV] [--pretty] --address=<address>
  516. --content=<value> [--export=<export>]
  517. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  518. [--home=<path>] [--sequence=<sequence>]
  519. --name=<name>
  520. --address=<address> Contract address
  521. --content=<value> Event content
  522. --export=<export> Transaction export directory
  523. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  524. --gw-port=<gwPort> Set the gateway port. Default: 8080
  525. -h, --help Show this help message and exit.
  526. --home=<path> Set the home directory.
  527. --pretty Pretty json print
  528. --sequence=<sequence> Sequence of the event
  529. --name=<name> Event name
  530. -V, --version Print version information and exit.
  531. ```
  532. - `address`,事件账户地址
  533. - `name`,事件名
  534. - `content`,事件内容
  535. - `sequence`,事件序号
  536. 如向账户地址`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`发布事件`n1`:`c1`:`-1`:
  537. ```bash
  538. :bin$ ./jdchain-cli.sh tx event --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --name n1 --content c1 --sequence -1
  539. select ledger, input the index:
  540. INDEX LEDGER
  541. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  542. > 0
  543. select keypair to sign tx:
  544. INDEX KEY ADDRESS
  545. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  546. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  547. > 0
  548. input password of the key:
  549. > 1
  550. event publish success
  551. ```
  552. #### 监听事件
  553. ```bash
  554. :bin$ ./jdchain-cli.sh tx event-listen -h
  555. Subscribe event.
  556. Usage: jdchain-cli tx event-listen [-hV] [--pretty] [--address=<address>]
  557. [--export=<export>] [--gw-host=<gwHost>]
  558. [--gw-port=<gwPort>] [--home=<path>]
  559. --name=<name> [--sequence=<sequence>]
  560. --address=<address> Event address
  561. --export=<export> Transaction export directory
  562. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  563. --gw-port=<gwPort> Set the gateway port. Default: 8080
  564. -h, --help Show this help message and exit.
  565. --home=<path> Set the home directory.
  566. --name=<name> Event name
  567. --pretty Pretty json print
  568. --sequence=<sequence> Sequence of the event
  569. -V, --version Print version information and exit.
  570. ```
  571. - `address`,事件账户地址,不传则表示监听系统事件
  572. - `name`,事件名,系统事件目前仅支持:`new_block_created`
  573. - `sequence`,起始监听序号
  574. 如监听系统新区块事件:
  575. ```bash
  576. :bin$ ./jdchain-cli.sh tx event-listen --name new_block_created --sequence 0
  577. select ledger, input the index:
  578. INDEX LEDGER
  579. 0 j5mXXoNsmh6qadnWLjxFMXobyNGsXT1PmTNzXiHyiYMxoP
  580. > 0
  581. # 会打印新区块事件:区块高度:最新区块高度
  582. New block:0:12
  583. New block:1:12
  584. New block:2:12
  585. ```
  586. #### 部署合约
  587. ```bash
  588. :bin$ ./jdchain-cli.sh tx contract-deploy -h
  589. Deploy or update contract.
  590. Usage: jdchain-cli tx contract-deploy [-hV] [--pretty] --car=<car>
  591. [--export=<export>] [--gw-host=<gwHost>]
  592. [--gw-port=<gwPort>] [--home=<path>]
  593. [--pubkey=<pubkey>]
  594. --car=<car> The car file path
  595. --export=<export> Transaction export directory
  596. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  597. --gw-port=<gwPort> Set the gateway port. Default: 8080
  598. -h, --help Show this help message and exit.
  599. --home=<path> Set the home directory.
  600. --pretty Pretty json print
  601. --pubkey=<pubkey> The pubkey of the exist contract
  602. -V, --version Print version information and exit.
  603. ```
  604. - `pubkey`,合约公钥,更新合约时使用
  605. - `car`,合约`car`文件
  606. 如将`contract-samples-1.5.0.RELEASE.car`文件中的合约部署上链:
  607. ```bash
  608. :bin$ ./jdchain-cli.sh tx contract-deploy --car /home/imuge/Desktop/jdchain-cli/1.5.0/contract-samples-1.5.0.RELEASE.car
  609. select ledger, input the index:
  610. INDEX LEDGER
  611. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  612. > 0
  613. select keypair to sign tx:
  614. INDEX KEY ADDRESS
  615. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  616. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  617. > 0
  618. input password of the key:
  619. > 1
  620. deploy contract: [LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH]
  621. ```
  622. 合约地址:`LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH`
  623. #### 修改合约权限
  624. ```bash
  625. :bin$ ./jdchain-cli.sh tx contract-permission -h
  626. Update contract permission.
  627. Usage: jdchain-cli tx contract-permission [-hV] [--pretty]
  628. [--address=<address>] [--export=<export>] [--gw-host=<gwHost>]
  629. [--gw-port=<gwPort>] [--home=<path>] [--mode=<mode>] [--role=<role>]
  630. --address=<address> Address of the contract
  631. --export=<export> Transaction export directory
  632. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  633. --gw-port=<gwPort> Set the gateway port. Default: 8080
  634. -h, --help Show this help message and exit.
  635. --home=<path> Set the home directory.
  636. --mode=<mode> Mode value of the contract
  637. --pretty Pretty json print
  638. --role=<role> Role of the contract
  639. -V, --version Print version information and exit.
  640. ```
  641. - `address`,合约地址
  642. - `role`,合约所属角色
  643. - `mode`,合约权限值
  644. 如:
  645. ```bash
  646. :bin$ ./jdchain-cli.sh tx contract-permission --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --role ROLE1 --mode 777
  647. select ledger, input the index:
  648. INDEX LEDGER
  649. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  650. > 0
  651. select keypair to sign tx:
  652. INDEX KEY ADDRESS
  653. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  654. > 0
  655. input password of the key:
  656. > 1
  657. update contract: [LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC] permission
  658. ```
  659. 将修改合约`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`所属角色为`ROLE1`,权限值为`777`(所有用户可读可写)。
  660. #### 合约调用
  661. ```bash
  662. :bin$ ./jdchain-cli.sh tx contract -h
  663. Call contract method.
  664. Usage: jdchain-cli tx contract [-hV] [--pretty] --address=<address>
  665. [--export=<export>] [--gw-host=<gwHost>]
  666. [--gw-port=<gwPort>] [--home=<path>]
  667. --method=<method> [--args=<args>[,<args>...]]...
  668. --address=<address> Contract address
  669. --args=<args>[,<args>...]
  670. Method arguments
  671. --export=<export> Transaction export directory
  672. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  673. --gw-port=<gwPort> Set the gateway port. Default: 8080
  674. -h, --help Show this help message and exit.
  675. --home=<path> Set the home directory.
  676. --method=<method> Contract method
  677. --pretty Pretty json print
  678. -V, --version Print version information and exit.
  679. ```
  680. - `address`,合约地址
  681. - `method`,合约方法
  682. - `args`,合约参数,半角逗号分割,命令行中会将所有参数处理为字符串,非字符串参数方法调用暂无法通过命令行工具调用
  683. 如调用合约`LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH`中`registerUser`方法,传参`ed386a148fcb48b281b325f66103c805`:
  684. ```bash
  685. :bin$ ./jdchain-cli.sh tx contract --address LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH --method registerUser --args ed386a148fcb48b281b325f66103c805
  686. select ledger, input the index:
  687. INDEX LEDGER
  688. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  689. > 0
  690. select keypair to sign tx:
  691. INDEX KEY ADDRESS
  692. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  693. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  694. > 0
  695. input password of the key:
  696. > 1
  697. call contract success
  698. return string: LdeNqvSjL4izfpMNsGpQiBpTBse4g6qLxZ6j5
  699. ```
  700. 调用成功并返回了字符串:`LdeNqvSjL4izfpMNsGpQiBpTBse4g6qLxZ6j5`
  701. #### 更新合约状态
  702. ```bash
  703. :bin$ ./jdchain-cli.sh tx contract-state -h
  704. Update contract state.
  705. Usage: jdchain-cli tx contract-state [-hV] [--pretty]
  706. --address=<address> [--export=<export>] [--gw-host=<gwHost>]
  707. [--gw-port=<gwPort>] [--home=<path>] --state=<state>
  708. --address=<address> Contract address
  709. --export=<export> Transaction export directory
  710. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  711. --gw-port=<gwPort> Set the gateway port. Default: 8080
  712. -h, --help Show this help message and exit.
  713. --home=<path> Set the home directory.
  714. --pretty Pretty json print
  715. --state=<state> Contract state,Optional values: FREEZE,NORMAL,
  716. REVOKE
  717. -V, --version Print version information and exit.
  718. ```
  719. - `address`,合约地址
  720. - `state`,合约状态,可选值:FREEZE,NORMAL,REVOKE
  721. 如冻结合约`LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W`:
  722. ```bash
  723. :bin$ $ ./jdchain-cli.sh tx contract-state --address LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W --state FREEZE
  724. select ledger, input the index:
  725. INDEX LEDGER
  726. 0 j5pFrMigE47t6TobQJXsztnoeA29H31v1vHHF1wqCp4rzi
  727. // 选择账本,当前网关服务只有上面一个可用账本
  728. > 0
  729. select keypair to sign tx:
  730. INDEX KEY ADDRESS
  731. 0 peer0 LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W
  732. // 选择链上已存在且有注册用户权限的用户所对应的公私钥对,用于交易签名
  733. > 0
  734. input password of the key:
  735. // 输入签名私钥密码
  736. > 1
  737. contract: [LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W] revoked
  738. ```
  739. 会冻结链上地址为`LdeNpEmyh5DMwbAwamxNaiJgMVGn6aTtQDA5W`的合约,此合约不能再被调用。
  740. #### 离线交易签名
  741. 1. 离线交易
  742. 执行以上所有交易时,若`export`参数不为空,则会执行交易写入本地操作,而非签名并发送交易
  743. 如构造合约调用操作交易并保存到本地:
  744. ```bash
  745. :bin$ ./jdchain-cli.sh tx contract --address LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH --method registerUser --args ed386a148fcb48b281b325f66103c810 --export /txs
  746. select ledger, input the index:
  747. INDEX LEDGER
  748. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  749. > 0
  750. export transaction success: /txs/j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3
  751. ```
  752. 交易内容会被序列化保存在`/txs/j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3`中,其中`j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3`是该交易哈希。
  753. 2. 离线签名
  754. ```bash
  755. :bin$ ./jdchain-cli.sh tx sign -h
  756. Sign transaction.
  757. Usage: jdchain-cli tx sign [-hV] [--pretty] [--export=<export>]
  758. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  759. [--home=<path>] [--tx=<txFile>]
  760. --export=<export> Transaction export directory
  761. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  762. --gw-port=<gwPort> Set the gateway port. Default: 8080
  763. -h, --help Show this help message and exit.
  764. --home=<path> Set the home directory.
  765. --tx=<txFile> Local transaction file
  766. --pretty Pretty json print
  767. -V, --version Print version information and exit.
  768. ```
  769. - `tx`,离线交易路径
  770. 如对步骤1中创建的离线交易添加终端用户(此用户需是链上存在的且有相关权限的用户)签名:
  771. ```bash
  772. :bin$ ./jdchain-cli.sh tx sign --tx /txs/j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3
  773. select keypair to sign tx:
  774. INDEX KEY ADDRESS
  775. 0 peer0 LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw
  776. 1 k1 LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  777. > 0
  778. input password of the key:
  779. > 1
  780. Sign transaction success!
  781. ```
  782. #### 离线交易发送
  783. 发送本地已经签名完成的交易
  784. ```bash
  785. :bin$ ./jdchain-cli.sh tx send -h
  786. Send transaction.
  787. Usage: jdchain-cli tx send [-hV] [--pretty] [--export=<export>]
  788. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  789. [--home=<path>] [--tx=<txFile>]
  790. --export=<export> Transaction export directory
  791. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  792. --gw-port=<gwPort> Set the gateway port. Default: 8080
  793. -h, --help Show this help message and exit.
  794. --home=<path> Set the home directory.
  795. --tx=<txFile> Local transaction file
  796. --pretty Pretty json print
  797. -V, --version Print version information and exit.
  798. ```
  799. - `tx`,离线交易路径
  800. 如发送`/txs/j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3`中包含的交易数据:
  801. ```bash
  802. :bin$ ./jdchain-cli.sh tx send --tx /home/imuge/Desktop/jdchain-cli/1.5.0/txs/j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3
  803. select ledger, input the index:
  804. INDEX LEDGER
  805. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  806. > 0
  807. Send transaction success: j5xR8ty8YbujTYKNRshmbfMYsL4jfe3yRUtMparmeHppd3
  808. ```