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.

query.md 47 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914
  1. ### 链上信息查询
  2. ```bash
  3. :bin$ ./jdchain-cli.sh query -h
  4. Usage: jdchain-cli query [-hV] [--pretty] [--gw-host=<gwHost>]
  5. [--gw-port=<gwPort>] [--home=<path>] [COMMAND]
  6. Query commands.
  7. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  8. Default: 127.0.0.1
  9. --gw-port=<gwPort> Set the gateway port. Default: 8080
  10. Default: 8080
  11. -h, --help Show this help message and exit.
  12. --home=<path> Set the home directory.
  13. Default: ../
  14. --pretty Pretty json print
  15. -V, --version Print version information and exit.
  16. Commands:
  17. ledgers Query ledgers.
  18. ledger Query ledger.
  19. participants Query participants.
  20. block Query block.
  21. txs-count Query transactions count.
  22. txs Query transactions.
  23. tx Query transaction.
  24. users Query users.
  25. users-count Query users count.
  26. user Query user.
  27. role-privileges Query role privileges.
  28. user-privileges Query user privileges.
  29. data-accounts-count Query data accounts count.
  30. data-accounts Query data accounts.
  31. data-account Query data account.
  32. kvs-count Query key-values count.
  33. kvs Query kvs.
  34. kv Query kv.
  35. user-event-accounts-count Query user event accounts count.
  36. user-event-accounts Query user event accounts.
  37. user-event-account Query user event account.
  38. user-event-names-count Query user event names count.
  39. user-event-names Query user event names.
  40. user-events-count Query user events count.
  41. user-events Query user events.
  42. latest-user-event Query latest user event.
  43. contracts-count Query contracts count.
  44. contracts Query contracts.
  45. contract Query contract.
  46. help Displays help information about the specified command
  47. ```
  48. 查询命令:[账本列表](#账本列表),[账本详情](#账本详情),[共识节点列表](#共识节点列表),[区块详情](#区块详情),[交易总数](#交易总数),[交易列表](#交易列表),[交易详情](#交易详情),[用户总数](#用户总数),[用户列表](#用户列表),[用户详情](#用户详情),[角色权限](#角色权限),[用户权限](#用户权限),[数据账户总数](#数据账户总数),[数据账户列表](#数据账户列表),[数据账户详情](#数据账户详情),[KV总数](#KV总数),[KV列表](#KV列表),[KV详情](#KV详情),[用户事件账户总数](#用户事件账户总数),[用户事件账户列表](#用户事件账户列表),[用户事件账户详情](#用户事件账户详情),[用户事件名总数](#用户事件名总数),[用户事件名列表](#用户事件名列表),[用户事件总数](#用户事件总数),[用户事件列表](#用户事件列表),[最新用户事件](#最新用户事件),[合约总数](#合约总数),[合约列表](#合约列表),[合约详情](#合约详情)
  49. #### 账本列表
  50. ```bash
  51. :bin$ ./jdchain-cli.sh query ledgers
  52. j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  53. ```
  54. 返回当前网关服务所有账本列表
  55. #### 账本详情
  56. 选择账本,打印当前账本详细信息:
  57. ```bash
  58. select ledger, input the index:
  59. INDEX LEDGER
  60. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  61. > 0
  62. {"hash":"j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg","latestBlockHash":"j5n8KGMFsRM7jzf99XK1jDK342fauj3myKcdgPJyLYyxws","latestBlockHeight":18}
  63. ```
  64. 可添加`--pretty`格式化输出`json`数据
  65. #### 共识节点列表
  66. 查询共识节点列表:
  67. ```bash
  68. :bin$ ./jdchain-cli.sh query participants
  69. select ledger, input the index:
  70. INDEX LEDGER
  71. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  72. > 0
  73. [{"address":"LdeNwsiuo7n6HULWhNKc87PBXJXAfGKFon9RE","id":2,"name":"2","participantNodeState":"CONSENSUS","pubKey":"7VeRFF1ednwhrFoe5cngKwPUJ2N4iFKD9Jt53GxSCc1MmPQ6"},{"address":"LdeNiXZbsBCsTc2ZGp1PGBX81aUxPekhwEwmY","id":1,"name":"1","participantNodeState":"CONSENSUS","pubKey":"7VeREmuT4fF9yRPEMbSSaNLKbLa3qoTpfGHRgwpnSWUn5tqW"},{"address":"LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw","id":0,"name":"0","participantNodeState":"CONSENSUS","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"},{"address":"LdeP2ji8PR1DPsLt5NoFeiBnhpckrLHgCJge6","id":3,"name":"3","participantNodeState":"CONSENSUS","pubKey":"7VeRGE4V9MR7HgAqTrkxGvJvaaKRZ3fAjHUjYzpNBGcjfAvr"}]
  74. ```
  75. 账本`j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg`中有四个共识节点,均为`CONSENSUS`状态
  76. #### 区块详情
  77. ```bash
  78. :bin$ ./jdchain-cli.sh query block -h
  79. Query block.
  80. Usage: jdchain-cli query block [-hV] [--pretty] [--gw-host=<gwHost>]
  81. [--gw-port=<gwPort>] [--hash=<hash>]
  82. [--height=<height>] [--home=<path>]
  83. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  84. --gw-port=<gwPort> Set the gateway port. Default: 8080
  85. -h, --help Show this help message and exit.
  86. --hash=<hash> Block hash
  87. --height=<height> Block height.
  88. --home=<path> Set the home directory.
  89. --pretty Pretty json print
  90. -V, --version Print version information and exit.
  91. ```
  92. - `height`,区块高度,默认`-1`查询当前最高区块
  93. 如:
  94. ```bash
  95. :bin$ ./jdchain-cli.sh query block --pretty
  96. select ledger, input the index:
  97. INDEX LEDGER
  98. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  99. > 0
  100. {
  101. "adminAccountHash":"j5p5z4es9RPrQWFu2nSJBQFT68byeGqAdUDu63qa5xV8Df",
  102. "contractAccountSetHash":"j5kbvGQ1tFH2GXgk8ThF1co7H2gCrFdeZn7Nibva7Md72P",
  103. "dataAccountSetHash":"j5fSmQkk8tb9v9SYDmaAko3oJJqmCm54HGbQwgbV2nTCVk",
  104. "hash":"j5n8KGMFsRM7jzf99XK1jDK342fauj3myKcdgPJyLYyxws",
  105. "height":18,
  106. "ledgerHash":"j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg",
  107. "previousHash":"j5motWQdmckqTxkG3x8DcE6quv2oGteKzsHqoV89Lfo4Mj",
  108. "timestamp":1627703544928,
  109. "transactionSetHash":"j5rc9PV5p9C8mXDAt8p9MR4QY3VAr4wQNG7zC3MSvFpcGG",
  110. "userAccountSetHash":"j5haZvthy9gGaJ8M3mEbwtpeUg9Z113ifZbcWtzAeQcQdu",
  111. "userEventSetHash":"j5nke9ZAnVRf1Qgg4u9Ske8RoZFbFVzVrKQid14qcqXaAn"
  112. }
  113. ```
  114. 返回当前最高区块详情
  115. #### 交易总数
  116. ```bash
  117. :bin$ ./jdchain-cli.sh query txs-count -h
  118. Query transactions count.
  119. Usage: jdchain-cli query txs-count [-hV] [--in-block] [--pretty]
  120. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  121. --height=<height> [--home=<path>]
  122. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  123. --gw-port=<gwPort> Set the gateway port. Default: 8080
  124. -h, --help Show this help message and exit.
  125. --height=<height> Block height.
  126. --home=<path> Set the home directory.
  127. --in-block In the given block.
  128. --pretty Pretty json print
  129. -V, --version Print version information and exit.
  130. ```
  131. - `height`,区块高度
  132. - `in-block`,是否只统计`height`参数指定区块数据
  133. 如查询高度`10`区块交易总数(会统计区块`0-10`内所有交易):
  134. ```bash
  135. :bin$ ./jdchain-cli.sh query txs-count --height 10
  136. select ledger, input the index:
  137. INDEX LEDGER
  138. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  139. > 0
  140. 11
  141. ```
  142. 查询高度`10`区块内交易总数(仅统计区块`10`交易):
  143. ```bash
  144. :bin$ ./jdchain-cli.sh query txs-count --height 10 --in-block
  145. select ledger, input the index:
  146. INDEX LEDGER
  147. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  148. > 0
  149. 1
  150. ```
  151. #### 交易列表
  152. ```bash
  153. :bin$ ./jdchain-cli.sh query txs -h
  154. Query transactions.
  155. Usage: jdchain-cli query txs [-hV] [--in-block] [--pretty] --count=<count>
  156. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  157. [--height=<height>] [--home=<path>] --index=<index>
  158. --count=<count> Transaction item count
  159. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  160. --gw-port=<gwPort> Set the gateway port. Default: 8080
  161. -h, --help Show this help message and exit.
  162. --height=<height> Block height.
  163. --home=<path> Set the home directory.
  164. --in-block In the given block.
  165. --index=<index> Transaction item index
  166. --pretty Pretty json print
  167. -V, --version Print version information and exit.
  168. ```
  169. - `height`,区块高度
  170. - `in-block`,是否只统计`height`参数指定区块数据
  171. - `index`,查询起始位置
  172. - `count`,最大返回
  173. 如查询高度`10`区块交易列表(会统计区块`0-10`内所有交易),从第`0`条开始,最大返回`1`条:
  174. ```bash
  175. :bin$ ./jdchain-cli.sh query txs --height 10 --index 0 --count 1
  176. select ledger, input the index:
  177. INDEX LEDGER
  178. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  179. > 0
  180. [{"request":{"endpointSignatures":[],"nodeSignatures":[{"digest":"SMHYntB7uTm3N4mReke4srWHhpDkjDFGRuz7Bis8quJt19igevwA4rEwNmZqFGGLMExgmrPvdGrxgRrhLhpxUo1KGW","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"},{"digest":"SMHbyCLcvds5sRKaWPptSjixxoaiwkQfM1noLGpLSvsmxwUSg4J55UhJtK1ZWiQp3rxy5FEMZpwHGkywexYuwXEWHo","pubKey":"7VeREmuT4fF9yRPEMbSSaNLKbLa3qoTpfGHRgwpnSWUn5tqW"},{"digest":"SMGP3a7GHW6qWbQY3ZXX5UBhHNFLrSkUzRLLfCFA9Gu6CJVoYVvBQjjCEzaYq9ox38DvyZJQFuLWPirV2G6VMeARqQ","pubKey":"7VeRFF1ednwhrFoe5cngKwPUJ2N4iFKD9Jt53GxSCc1MmPQ6"},{"digest":"SMHGzmEVzZPKyvN3zC6nLbVypufWEfd6cFvnMMjuEXFk5WncLeUx4CyAohTnNLP21ksJ6r15usowbkRFeaUYQgJkre","pubKey":"7VeRGE4V9MR7HgAqTrkxGvJvaaKRZ3fAjHUjYzpNBGcjfAvr"}],"transactionContent":{"operations":[{"@type":"com.jd.blockchain.ledger.LedgerInitOperation","initSetting":{"consensusParticipants":[{"address":"LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw","id":0,"name":"0","participantNodeState":"CONSENSUS","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"},{"address":"LdeNiXZbsBCsTc2ZGp1PGBX81aUxPekhwEwmY","id":1,"name":"1","participantNodeState":"CONSENSUS","pubKey":"7VeREmuT4fF9yRPEMbSSaNLKbLa3qoTpfGHRgwpnSWUn5tqW"},{"address":"LdeNwsiuo7n6HULWhNKc87PBXJXAfGKFon9RE","id":2,"name":"2","participantNodeState":"CONSENSUS","pubKey":"7VeRFF1ednwhrFoe5cngKwPUJ2N4iFKD9Jt53GxSCc1MmPQ6"},{"address":"LdeP2ji8PR1DPsLt5NoFeiBnhpckrLHgCJge6","id":3,"name":"3","participantNodeState":"CONSENSUS","pubKey":"7VeRGE4V9MR7HgAqTrkxGvJvaaKRZ3fAjHUjYzpNBGcjfAvr"}],"consensusProvider":"com.jd.blockchain.consensus.bftsmart.BftsmartConsensusProvider","consensusSettings":"115kLavjaNTn9Grf9orxPmABexqr5Dvac5LEyhWXbQCd4vEScsxxGTEtyrgDfCwLsNBGYQBj8UGkEPCZNsWNMrH8H2naZUsszwbwnSka6jgahxJepH6jDRMP4X31qxksorr23dpwfemhezwVUbTNyvu54HW76wmtvAyCk7m3DKE1CJhLtDTXAWt8LjqE3xhNXfKZJLT2np69nKDqi41hGVYjZfPz4ZmUzuo34ae3syvgKDPYJCNscSP7UoJgvk142x7ggy8KX2bbENZSUSdbV9qLzPDfsdnkLFDzyDJjd6wMxdzV4Tb9fh5WvkciYyh1SE2Ew7peoaLmUDEULd9LKCKmJYXhPCmbbjxecLYvtcUoarGMHKpHKxDAQZjsX3ik5o8B1WwnQG8VazZEZbepDVtX8p1T7TGryXJUZfGZ6ajKX8shE2PpvkjWTMXgW1ebwPKLziqpzxcBLy1pBTtwztgnexbzCGCUYTgS9FiEfn3aRuhHKhzHfAe6gH6Lkk4PQWeAKScPrG1PzQKNRpxJfxZJV3ZBEesDvV85i2HT829tvATUfdUK8s5Zhy9TT33ZrkkC3QWH6saFBCCHyq9gUGrMgWXi5jn5D2GqNwWFJSvDXRNzYArvqkcqCB5gzfP23kYq9RKVvonvtmhww5hdLGzHdSU19dghHkyvbYi4VSFT57QQET7z7qvQYSNxDbCWNfn2osNipdMmFWY7AVetZvkowQPEZqr5xYV8j9pawam4WETomeeEPb11BhXXmyBbhuJx3xpNPcfFHE2Y52NcM7LdLxpmkdBgpFTdLh5Y3mGup6opJWp8WzXzi5zHsM5eXxyfq2uQ9ttQB5KPwTi1wgAskDdcgYRtH3MmVMB1MBHVAGAu2asZpRWXnZT39iPzshzJRck1PC2yhiYq8We5wfMgoA4KDPxp55wwWNtPpC1fBpjsNuLtqiHYSdZxTy32dASA1Zmm3XPFhPm6vcbCcod2n4uUSK2Vv9gMtzVVmprstVoB47whfhvgerfPiHMEJemeG5sF5vKcxMrpAxZtM4sHNMJf9xPucMTUzyWcSbyvSsRshFjnHRAEhSGHSCzRrjsTiLo2KZyLrzyBBc6DqdwdNC1RnmgirS1baaL2xTg3jkQystmH5VNJ5EQRVPqKQeSDXw9tUAHqMyknmL4zdZJjkfnw7rRXueQayHsfH4FGodGoNxJdYkbyjrYyrQZM8BeCLYHEqEyxKyAJHGm2kt96Cj8v6z9Ezv6CRh8ZZgnQBSvVvWtK1NWmjA1ZAf6fNv3KAEUsXfM6fy37HrThd9tqH32S25b3GeFJh8evnVou33hqK7JNwEk6o4ymwNWjuWMzqjp4Ag7jrFe5h5HG1J8NZg1KZKLvK2PChyR1oyNz1dH6RkguEz6XENhWLnmiuzPPbN4RrXSWWbgtjjbgM7megLEB5J8AqBnKR7RM1Gt3KB41xQx1F3yLCkhVXwYFUijdMtCNwCQKdBRSB9K6fBoSXbFcxzBFhNVc4x6g3CdZzC8F2Yewa1eZubcsZYyeVCSX6x1wBeocpZwsy2b9KxTQevuHuhJ1fpLjTLBFcfqbaC3NxGr2Q391fPzUsNTNvybsh7vySRyFtskYJ4ZJnUrviHUgnk7AbsBjKMxweaMur3ykm5dGgvTJT2EgbuqCNFPpcV2w1v6fFnALYMipvHWtszY4JSC8T5JERVhttBY9esq1dzoddpMNuKJvqkASaRDADJ6muMjDgXUeYkNtqftCohLxNPz4r49jbmeaFJgqdNCWEbdE4SqBeJpLjsUUfcpeNRXmJkCD8G9kV4njBniJP5pgoU1CDNYjDgAjvXx6kzSnEmtYGdzRCbmkUUPEJaXMVi3UnjmbRWcnkt979xwepW7KyhpvrWmxHrsqge6YfPLNbfNB5xohVuAbQkJgS5b1S8SJGDs1DEG1hxzEpby4HVBDehyzUZjSKKfJeh3NzkJ9khswYJ5jCZgjrwndf8kLKNbgVpTxoipSVPyswavLpE6BQ271GHatniVZFyRqFD4NnZ6a9LvwB5LdfRziXoUUF6wejAx7oy6yw5bF1LzAuZogAjRVbGXZ2wR4LYf4FszM8R2G6UEzNGW3jiXNG7iUJJV1orfjgdJHAFh2miDojxi3iRL1WnQSuYcj5jtse85m2iMWsB7USrMoFzkSuh7ST4VoNvLEr2SugYxuek8pcVCKvKiBbZXTwEEDSh59R2cYSZJ6uGSKy2BJyizb3ShUdbp8gMzVN9jdbDnTkfFyz8jzySes58gs8M8J9m4P1cxNYNXm7aZLroUZhw2iUS5tzq5ttxYVT7oQoBUrQiAwfzGv55Pbthbq4A7NaiihbhUHFGAFpkmLM9T4vMWsi7","createdTime":1627618941000,"cryptoSetting":{"autoVerifyHash":true,"hashAlgorithm":8216,"supportedProviders":[{"algorithms":[{},{},{},{},{},{},{}],"name":"com.jd.blockchain.crypto.service.classic.ClassicCryptoService"},{"algorithms":[{},{},{}],"name":"com.jd.blockchain.crypto.service.sm.SMCryptoService"}]},"ledgerSeed":"kULN7uzXyZuC7rD9BMLIgA==","ledgerStructureVersion":-1}},{"@type":"com.jd.blockchain.ledger.UserRegisterOperation","userID":{"address":"LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"}},{"@type":"com.jd.blockchain.ledger.UserRegisterOperation","userID":{"address":"LdeNiXZbsBCsTc2ZGp1PGBX81aUxPekhwEwmY","pubKey":"7VeREmuT4fF9yRPEMbSSaNLKbLa3qoTpfGHRgwpnSWUn5tqW"}},{"@type":"com.jd.blockchain.ledger.UserRegisterOperation","userID":{"address":"LdeNwsiuo7n6HULWhNKc87PBXJXAfGKFon9RE","pubKey":"7VeRFF1ednwhrFoe5cngKwPUJ2N4iFKD9Jt53GxSCc1MmPQ6"}},{"@type":"com.jd.blockchain.ledger.UserRegisterOperation","userID":{"address":"LdeP2ji8PR1DPsLt5NoFeiBnhpckrLHgCJge6","pubKey":"7VeRGE4V9MR7HgAqTrkxGvJvaaKRZ3fAjHUjYzpNBGcjfAvr"}},{"@type":"com.jd.blockchain.ledger.RolesConfigureOperation","roles":[{"disableLedgerPermissions":[],"disableTransactionPermissions":[],"enableLedgerPermissions":["CONFIGURE_ROLES","AUTHORIZE_USER_ROLES","SET_CONSENSUS","SET_CRYPTO","REGISTER_PARTICIPANT","REGISTER_USER","REGISTER_DATA_ACCOUNT","REGISTER_CONTRACT","UPGRADE_CONTRACT","SET_USER_ATTRIBUTES","WRITE_DATA_ACCOUNT","APPROVE_TX","CONSENSUS_TX","REGISTER_EVENT_ACCOUNT","WRITE_EVENT_ACCOUNT"],"enableTransactionPermissions":["DIRECT_OPERATION","CONTRACT_OPERATION"],"roleName":"DEFAULT"}]},{"@type":"com.jd.blockchain.ledger.UserAuthorizeOperation","userRolesAuthorizations":[{"authorizedRoles":[],"policy":"UNION","unauthorizedRoles":[],"userAddresses":["LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw"]}]},{"@type":"com.jd.blockchain.ledger.UserAuthorizeOperation","userRolesAuthorizations":[{"authorizedRoles":[],"policy":"UNION","unauthorizedRoles":[],"userAddresses":["LdeNiXZbsBCsTc2ZGp1PGBX81aUxPekhwEwmY"]}]},{"@type":"com.jd.blockchain.ledger.UserAuthorizeOperation","userRolesAuthorizations":[{"authorizedRoles":[],"policy":"UNION","unauthorizedRoles":[],"userAddresses":["LdeNwsiuo7n6HULWhNKc87PBXJXAfGKFon9RE"]}]},{"@type":"com.jd.blockchain.ledger.UserAuthorizeOperation","userRolesAuthorizations":[{"authorizedRoles":[],"policy":"UNION","unauthorizedRoles":[],"userAddresses":["LdeP2ji8PR1DPsLt5NoFeiBnhpckrLHgCJge6"]}]}],"timestamp":1627618941000},"transactionHash":"j5vJGDBQLi6Vo5Gxtsab1vyL2TFaf1NoXDi6Xv2uvCcj9T"},"result":{"blockHeight":0,"dataSnapshot":{"adminAccountHash":"j5u4gqeAkKb3DoELpXP9bDgAxCVRQgKsguPvE1Wc9re1UT","userAccountSetHash":"j5hzkPPBJAqKs4rLWbEiFhbh1VW6Jc2xk878X5A6JywPnC"},"executionState":"SUCCESS","transactionHash":"j5vJGDBQLi6Vo5Gxtsab1vyL2TFaf1NoXDi6Xv2uvCcj9T"}}]
  181. ```
  182. 查询高度`10`区块内交易列表(仅统计区块`10`交易),从第`0`条开始,最大返回`1`:
  183. ```bash
  184. :bin$ ./jdchain-cli.sh query txs --height 10 --index 0 --count 1 --in-block
  185. select ledger, input the index:
  186. INDEX LEDGER
  187. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  188. > 0
  189. [{"request":{"endpointSignatures":[{"digest":"SMKgce34AxQ8JEDDZY3x7iMvbL5QymiC93XPWqSirUB2AN8rvx18ynDS9f1zFA6QyXQNowA1XNhaLWnArrt7JHHxhY","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"}],"nodeSignatures":[{"digest":"SMKgce34AxQ8JEDDZY3x7iMvbL5QymiC93XPWqSirUB2AN8rvx18ynDS9f1zFA6QyXQNowA1XNhaLWnArrt7JHHxhY","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"}],"transactionContent":{"ledgerHash":"j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg","operations":[{"@type":"com.jd.blockchain.ledger.DataAccountKVSetOperation","accountAddress":"LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC","writeSet":[{"expectedVersion":-1,"key":"k1","value":{"bytes":"djE=","type":"TEXT"}}]}],"timestamp":1627632026435},"transactionHash":"j5fo2aAwp2tsneHm4wE8AnWLV7CKyax7BLWJqJm2V3WsrD"},"result":{"blockHeight":10,"dataSnapshot":{"adminAccountHash":"j5p5z4es9RPrQWFu2nSJBQFT68byeGqAdUDu63qa5xV8Df","dataAccountSetHash":"j5fSmQkk8tb9v9SYDmaAko3oJJqmCm54HGbQwgbV2nTCVk","userAccountSetHash":"j5mwiewVaxPLYQciovrB9nShWD5nr7YYFopbmWx28jqiFH","userEventSetHash":"j5wf9v6ixDDSD2gRi47r3vomkmTaRCqSLNbaNxrKcVdtD7"},"executionState":"SUCCESS","transactionHash":"j5fo2aAwp2tsneHm4wE8AnWLV7CKyax7BLWJqJm2V3WsrD"}}]
  190. ```
  191. #### 交易详情
  192. ```bash
  193. e:bin$ ./jdchain-cli.sh query tx -h
  194. Query transaction.
  195. Usage: jdchain-cli query tx [-hV] [--pretty] [--gw-host=<gwHost>]
  196. [--gw-port=<gwPort>] [--hash=<hash>] [--home=<path>]
  197. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  198. --gw-port=<gwPort> Set the gateway port. Default: 8080
  199. -h, --help Show this help message and exit.
  200. --hash=<hash> Transaction hash
  201. --home=<path> Set the home directory.
  202. --pretty Pretty json print
  203. -V, --version Print version information and exit.
  204. ```
  205. - `hash`,交易哈希
  206. 如查询交易`j5fo2aAwp2tsneHm4wE8AnWLV7CKyax7BLWJqJm2V3WsrD`详情:
  207. ```bash
  208. :bin$ ./jdchain-cli.sh query tx --hash j5fo2aAwp2tsneHm4wE8AnWLV7CKyax7BLWJqJm2V3WsrD
  209. select ledger, input the index:
  210. INDEX LEDGER
  211. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  212. > 0
  213. {"request":{"endpointSignatures":[{"digest":"SMKgce34AxQ8JEDDZY3x7iMvbL5QymiC93XPWqSirUB2AN8rvx18ynDS9f1zFA6QyXQNowA1XNhaLWnArrt7JHHxhY","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"}],"nodeSignatures":[{"digest":"SMKgce34AxQ8JEDDZY3x7iMvbL5QymiC93XPWqSirUB2AN8rvx18ynDS9f1zFA6QyXQNowA1XNhaLWnArrt7JHHxhY","pubKey":"7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn"}],"transactionContent":{"ledgerHash":"j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg","operations":[{"@type":"com.jd.blockchain.ledger.DataAccountKVSetOperation","accountAddress":"LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC","writeSet":[{"expectedVersion":-1,"key":"k1","value":{"bytes":"djE=","type":"TEXT"}}]}],"timestamp":1627632026435},"transactionHash":"j5fo2aAwp2tsneHm4wE8AnWLV7CKyax7BLWJqJm2V3WsrD"},"result":{"blockHeight":10,"dataSnapshot":{"adminAccountHash":"j5p5z4es9RPrQWFu2nSJBQFT68byeGqAdUDu63qa5xV8Df","dataAccountSetHash":"j5fSmQkk8tb9v9SYDmaAko3oJJqmCm54HGbQwgbV2nTCVk","userAccountSetHash":"j5mwiewVaxPLYQciovrB9nShWD5nr7YYFopbmWx28jqiFH","userEventSetHash":"j5wf9v6ixDDSD2gRi47r3vomkmTaRCqSLNbaNxrKcVdtD7"},"executionState":"SUCCESS","transactionHash":"j5fo2aAwp2tsneHm4wE8AnWLV7CKyax7BLWJqJm2V3WsrD"}}
  214. ```
  215. #### 用户总数
  216. 查询用户总数:
  217. ```bash
  218. :bin$ ./jdchain-cli.sh query users-count
  219. select ledger, input the index:
  220. INDEX LEDGER
  221. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  222. > 0
  223. 10
  224. ```
  225. 当前区块链网络共有`10`个用户
  226. #### 用户列表
  227. ```bash
  228. :bin$ ./jdchain-cli.sh query users -h
  229. Query users.
  230. Usage: jdchain-cli query users [-hV] [--pretty] --count=<count>
  231. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  232. [--home=<path>] --index=<index>
  233. --count=<count> User item count
  234. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  235. --gw-port=<gwPort> Set the gateway port. Default: 8080
  236. -h, --help Show this help message and exit.
  237. --home=<path> Set the home directory.
  238. --index=<index> User item index
  239. --pretty Pretty json print
  240. -V, --version Print version information and exit.
  241. ```
  242. - `index`,起始位置
  243. - `count`,最大返回
  244. 如分页查询用户列表,从第`0`个开始,最大返回`10`条:
  245. ```bash
  246. :bin$ ./jdchain-cli.sh query users --index 0 --count 10
  247. select ledger, input the index:
  248. INDEX LEDGER
  249. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  250. > 0
  251. ADDRESS PUBKEY
  252. LdeP2ji8PR1DPsLt5NoFeiBnhpckrLHgCJge6 7VeRGE4V9MR7HgAqTrkxGvJvaaKRZ3fAjHUjYzpNBGcjfAvr
  253. LdeNq3862vtUCeptww1T5mVvLbAeppYqVNdqD 7VeRGuwP2iUykAL4beftP1DuDTj7y2uFGEM6mx3Dy7YSm2j1
  254. LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC 7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk
  255. LdeNyibeafrAQXgHjBxgQxoLbna6hL4BcXZiw 7VeRJpb2XX8XKAaC7G5zQg9DbgKM8gmLhUBtGFmerFbhJTZn
  256. LdeNwTWpyzqioLURrHQuoGcnwA6YLiFWn3LNn 7VeRH7BsRntvJmomjw7YvF5HZVsSMb48GKzPnAP7iekRCLGq
  257. LdeNiXZbsBCsTc2ZGp1PGBX81aUxPekhwEwmY 7VeREmuT4fF9yRPEMbSSaNLKbLa3qoTpfGHRgwpnSWUn5tqW
  258. LdeNisM5oTypwPYv9tnhFNosRjCyXzzViU4SA 7VeREyEcDcY85DRdWAEsmJ4Moh89eE21AU2LEDbYG3t3MrGo
  259. LdeNqvSjL4izfpMNsGpQiBpTBse4g6qLxZ6j5 7VeRFd2LB8ZmYnVNc2pux5TwVqHv3pwT6JXoF3fzDon9bSXK
  260. LdeNwsiuo7n6HULWhNKc87PBXJXAfGKFon9RE 7VeRFF1ednwhrFoe5cngKwPUJ2N4iFKD9Jt53GxSCc1MmPQ6
  261. LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB 7VeRMGBMMBQVoZQTU3mcJYGgbVcQzxXiq6NK69TaCjEoktLf
  262. ```
  263. 返回`10`个用户的地址和公私钥信息
  264. | 由于`JD Chain`网络并不保证用户(数据账户/事件账户/合约账户)按创建顺序排列,所以当有新的用户注册后,前后两次相同参数的查询数据可能不一致!!!
  265. #### 用户详情
  266. ```bash
  267. :bin$ ./jdchain-cli.sh query user -h
  268. Query user.
  269. Usage: jdchain-cli query user [-hV] [--pretty] --address=<address>
  270. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  271. [--home=<path>]
  272. --address=<address> User address
  273. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  274. --gw-port=<gwPort> Set the gateway port. Default: 8080
  275. -h, --help Show this help message and exit.
  276. --home=<path> Set the home directory.
  277. --pretty Pretty json print
  278. -V, --version Print version information and exit.
  279. ```
  280. - `address`,用户地址
  281. 根据地址`LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB`查询用户详情:
  282. ```bash
  283. :bin$ ./jdchain-cli.sh query user --address LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB
  284. select ledger, input the index:
  285. INDEX LEDGER
  286. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  287. > 0
  288. {"address":"LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB","pubKey":"7VeRMGBMMBQVoZQTU3mcJYGgbVcQzxXiq6NK69TaCjEoktLf"}
  289. ```
  290. #### 角色权限
  291. ```bash
  292. :bin$ ./jdchain-cli.sh query role-privileges -h
  293. Query role privileges.
  294. Usage: jdchain-cli query role-privileges [-hV] [--pretty] [--gw-host=<gwHost>]
  295. [--gw-port=<gwPort>] [--home=<path>] --role=<role>
  296. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  297. --gw-port=<gwPort> Set the gateway port. Default: 8080
  298. -h, --help Show this help message and exit.
  299. --home=<path> Set the home directory.
  300. --pretty Pretty json print
  301. --role=<role> Role name
  302. -V, --version Print version information and exit.
  303. ```
  304. - `role`,角色名称
  305. 查询角色`ROLE1`权限信息:
  306. ```bash
  307. :bin$ ./jdchain-cli.sh query role-privileges --role ROLE1
  308. select ledger, input the index:
  309. INDEX LEDGER
  310. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  311. > 0
  312. {"ledgerPrivilege":{"permissionCount":2,"privilege":["REGISTER_USER","REGISTER_DATA_ACCOUNT"]},"transactionPrivilege":{"permissionCount":2,"privilege":["DIRECT_OPERATION","CONTRACT_OPERATION"]}}
  313. ```
  314. #### 用户权限
  315. ```bash
  316. :bin$ ./jdchain-cli.sh query user-privileges -h
  317. Query user privileges.
  318. Usage: jdchain-cli query user-privileges [-hV] [--pretty] --address=<address>
  319. [--gw-host=<gwHost>] [--gw-port=<gwPort>] [--home=<path>]
  320. --address=<address> User address
  321. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  322. --gw-port=<gwPort> Set the gateway port. Default: 8080
  323. -h, --help Show this help message and exit.
  324. --home=<path> Set the home directory.
  325. --pretty Pretty json print
  326. -V, --version Print version information and exit.
  327. ```
  328. - `address`,用户地址
  329. 查询用户`LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB`权限信息:
  330. ```bash
  331. :bin$ ./jdchain-cli.sh query user-privileges --address LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB
  332. select ledger, input the index:
  333. INDEX LEDGER
  334. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  335. > 0
  336. {"ledgerPrivilegesBitset":{"privilege":["CONFIGURE_ROLES","AUTHORIZE_USER_ROLES","SET_CONSENSUS","SET_CRYPTO","REGISTER_PARTICIPANT","REGISTER_USER","REGISTER_DATA_ACCOUNT","REGISTER_CONTRACT","UPGRADE_CONTRACT","SET_USER_ATTRIBUTES","WRITE_DATA_ACCOUNT","APPROVE_TX","CONSENSUS_TX","REGISTER_EVENT_ACCOUNT","WRITE_EVENT_ACCOUNT"]},"transactionPrivilegesBitset":{"privilege":["DIRECT_OPERATION","CONTRACT_OPERATION"]},"userAddress":"LdeNufGZewrvS7sE4VWC9m1SFkPqVwjBN87LB","userRole":["DEFAULT"]}
  337. ```
  338. #### 数据账户总数
  339. 查询数据账户总数:
  340. ```bash
  341. :bin$ ./jdchain-cli.sh query data-accounts-count
  342. select ledger, input the index:
  343. INDEX LEDGER
  344. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  345. > 0
  346. 1
  347. ```
  348. 当前账本共有一个数据账户
  349. #### 数据账户列表
  350. ```bash
  351. :bin$ ./jdchain-cli.sh query data-accounts -h
  352. Query data accounts.
  353. Usage: jdchain-cli query data-accounts [-hV] [--pretty] --count=<count>
  354. [--gw-host=<gwHost>]
  355. [--gw-port=<gwPort>] [--home=<path>]
  356. --index=<index>
  357. --count=<count> Data account item count
  358. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  359. --gw-port=<gwPort> Set the gateway port. Default: 8080
  360. -h, --help Show this help message and exit.
  361. --home=<path> Set the home directory.
  362. --index=<index> Data account item index
  363. --pretty Pretty json print
  364. -V, --version Print version information and exit.
  365. ```
  366. - `index`,起始位置
  367. - `count`,最大返回
  368. 如分页查询数据账户列表,从第`0`个开始,最大返回`10`条:
  369. ```bash
  370. :bin$ ./jdchain-cli.sh query data-accounts --index 0 --count 10
  371. select ledger, input the index:
  372. INDEX LEDGER
  373. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  374. > 0
  375. ADDRESS PUBKEY
  376. LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC 7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk
  377. ```
  378. 返回数据账户的地址和公私钥信息
  379. #### 数据账户详情
  380. ```bash
  381. :bin$ ./jdchain-cli.sh query data-account -h
  382. Query data account.
  383. Usage: jdchain-cli query data-account [-hV] [--pretty] --address=<address>
  384. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  385. [--home=<path>]
  386. --address=<address> Data account address
  387. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  388. --gw-port=<gwPort> Set the gateway port. Default: 8080
  389. -h, --help Show this help message and exit.
  390. --home=<path> Set the home directory.
  391. --pretty Pretty json print
  392. -V, --version Print version information and exit.
  393. ```
  394. - `address`,数据账户地址
  395. 查询数据账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`详情:
  396. ```bash
  397. :bin$ ./jdchain-cli.sh query data-account --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  398. select ledger, input the index:
  399. INDEX LEDGER
  400. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  401. > 0
  402. {"address":"LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC","dataRootHash":"j5vyv6SmvSXQNKyjsEVCQJsyqXxKGZMBU62fKvtdJm2W4y","headerRootHash":"j5sA2KPgY9vidgTUCjCJiscn2CXapgSJsVnWe54xXKohej","pubKey":"7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk"}
  403. ```
  404. #### KV总数
  405. ```bash
  406. :bin$ ./jdchain-cli.sh query kvs-count -h
  407. Query key-values count.
  408. Usage: jdchain-cli query kvs-count [-hV] [--pretty] --address=<address>
  409. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  410. [--home=<path>]
  411. --address=<address> Data account address
  412. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  413. --gw-port=<gwPort> Set the gateway port. Default: 8080
  414. -h, --help Show this help message and exit.
  415. --home=<path> Set the home directory.
  416. --pretty Pretty json print
  417. -V, --version Print version information and exit.
  418. ```
  419. - `address`,数据账户地址
  420. 查询数据账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`中`kv`数据总数:
  421. ```bash
  422. :bin$ ./jdchain-cli.sh query kvs-count --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  423. select ledger, input the index:
  424. INDEX LEDGER
  425. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  426. > 0
  427. 1
  428. ```
  429. 共有一个`kv`
  430. #### KV列表
  431. ```bash
  432. :bin$ ./jdchain-cli.sh query kvs -h
  433. Query kvs.
  434. Usage: jdchain-cli query kvs [-hV] [--pretty] --address=<address>
  435. --count=<count> [--gw-host=<gwHost>]
  436. [--gw-port=<gwPort>] [--home=<path>]
  437. --index=<index>
  438. --address=<address> Data account address
  439. --count=<count> KV item count
  440. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  441. --gw-port=<gwPort> Set the gateway port. Default: 8080
  442. -h, --help Show this help message and exit.
  443. --home=<path> Set the home directory.
  444. --index=<index> KV item index
  445. --pretty Pretty json print
  446. -V, --version Print version information and exit.
  447. ```
  448. - `address`,数据账户地址
  449. - `index`,起始位置
  450. - `count`,最大返回
  451. 如分页查询数据账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`中`kv`列表,从第`0`个开始,最大返回`10`条:
  452. ```bash
  453. :bin$ ./jdchain-cli.sh query kvs --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --index 0 --count 10
  454. select ledger, input the index:
  455. INDEX LEDGER
  456. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  457. > 0
  458. {"key":"k1","type":"TEXT","value":"v1","version":0}
  459. ```
  460. #### KV详情
  461. ```bash
  462. :bin$ ./jdchain-cli.sh query kv -h
  463. Query kv.
  464. Usage: jdchain-cli query kv [-hV] [--pretty] --address=<address>
  465. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  466. [--home=<path>] --key=<key>
  467. --address=<address> Data account address
  468. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  469. --gw-port=<gwPort> Set the gateway port. Default: 8080
  470. -h, --help Show this help message and exit.
  471. --home=<path> Set the home directory.
  472. --key=<key> Key
  473. --pretty Pretty json print
  474. -V, --version Print version information and exit.
  475. ```
  476. - `address`,数据账户地址
  477. - `key`,`key`
  478. 查询数据账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`中`k1`最新数据:
  479. ```bash
  480. :bin$ ./jdchain-cli.sh query kv --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --key k1
  481. select ledger, input the index:
  482. INDEX LEDGER
  483. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  484. > 0
  485. {"key":"k1","type":"TEXT","value":"v1","version":0}
  486. ```
  487. #### 用户事件账户总数
  488. 查询数据账户总数:
  489. ```bash
  490. :bin$ ./jdchain-cli.sh query user-event-accounts-count
  491. select ledger, input the index:
  492. INDEX LEDGER
  493. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  494. > 0
  495. 4
  496. ```
  497. 当前账本共有`4`个数据账户
  498. #### 用户事件账户列表
  499. ```bash
  500. :bin$ ./jdchain-cli.sh query user-event-accounts -h
  501. Query user event accounts.
  502. Usage: jdchain-cli query user-event-accounts [-hV] [--pretty] --count=<count>
  503. [--gw-host=<gwHost>] [--gw-port=<gwPort>] [--home=<path>] --index=<index>
  504. --count=<count> Event account item count
  505. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  506. --gw-port=<gwPort> Set the gateway port. Default: 8080
  507. -h, --help Show this help message and exit.
  508. --home=<path> Set the home directory.
  509. --index=<index> Event account item index
  510. --pretty Pretty json print
  511. -V, --version Print version information and exit.
  512. ```
  513. - `index`,起始位置
  514. - `count`,最大返回
  515. 如分页查询用户事件账户列表,从第`0`个开始,最大返回`10`条:
  516. ```bash
  517. :bin$ ./jdchain-cli.sh query user-event-accounts --index 0 --count 10
  518. select ledger, input the index:
  519. INDEX LEDGER
  520. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  521. > 0
  522. ADDRESS PUBKEY
  523. LdeNhAxxXjbh56LqeB7xHpgZgHG6GDTZ45GgJ 7VeR82o3hZy1AVEjmxfNpHHW3d1zabbELmJUnijGkKJNDXu5
  524. LdeP33nxsYxYgaELQUkd8tBsTmwrkySiqnAVF 7VeRBA5zD2EDCiRtsiHzMQUEPf52hjKwhAi6PfNCgoiRQrSw
  525. LdeNnDJyqYgxDernBf6Vh68CkM5FbJNYtQCPA 7VeRB71W3anhCBretEP2R9YjiFB7ne2o5qhsivPo3XmHZ7cJ
  526. LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC 7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk
  527. ```
  528. 返回用户事件账户的地址和公私钥信息
  529. #### 用户事件账户详情
  530. ```bash
  531. :bin$ ./jdchain-cli.sh query user-event-account -h
  532. Query user event account.
  533. Usage: jdchain-cli query user-event-account [-hV] [--pretty]
  534. --address=<address> [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  535. [--home=<path>]
  536. --address=<address> Event account address
  537. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  538. --gw-port=<gwPort> Set the gateway port. Default: 8080
  539. -h, --help Show this help message and exit.
  540. --home=<path> Set the home directory.
  541. --pretty Pretty json print
  542. -V, --version Print version information and exit.
  543. ```
  544. - `address`,用户事件账户地址
  545. 查询事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`详情:
  546. ```bash
  547. :bin$ ./jdchain-cli.sh query user-event-account --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  548. select ledger, input the index:
  549. INDEX LEDGER
  550. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  551. > 0
  552. {"address":"LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC","pubKey":"7VeRFk4ANQHjWjAmAoL7492fuykTpXujihJeAgbXT2J9H9Yk"}
  553. ```
  554. #### 用户事件名总数
  555. ```bash
  556. :bin$ ./jdchain-cli.sh query user-event-names-count -h
  557. Query user event names count.
  558. Usage: jdchain-cli query user-event-names-count [-hV] [--pretty]
  559. --address=<address> [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  560. [--home=<path>]
  561. --address=<address> Event account address
  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. --pretty Pretty json print
  567. -V, --version Print version information and exit.
  568. ```
  569. - `address`,用户事件账户地址
  570. 查询事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`事件名总数:
  571. ```bash
  572. :bin$ ./jdchain-cli.sh query user-event-names-count --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC
  573. select ledger, input the index:
  574. INDEX LEDGER
  575. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  576. > 0
  577. 1
  578. ```
  579. #### 用户事件名列表
  580. ```bash
  581. :bin$ ./jdchain-cli.sh query user-event-names -h
  582. Query user event names.
  583. Usage: jdchain-cli query user-event-names [-hV] [--pretty] --address=<address>
  584. --count=<count> [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  585. [--home=<path>] --index=<index>
  586. --address=<address> Event account address
  587. --count=<count> Event name item count
  588. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  589. --gw-port=<gwPort> Set the gateway port. Default: 8080
  590. -h, --help Show this help message and exit.
  591. --home=<path> Set the home directory.
  592. --index=<index> Event name item index
  593. --pretty Pretty json print
  594. -V, --version Print version information and exit.
  595. ```
  596. - `address`,事件账户地址
  597. - `index`,起始位置
  598. - `count`,最大返回
  599. 如分页查询用户事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`事件名列表,从第`0`个开始,最大返回`10`条:
  600. ```bash
  601. :bin$ ./jdchain-cli.sh query user-event-names --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --index 0 --count 10
  602. select ledger, input the index:
  603. INDEX LEDGER
  604. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  605. > 0
  606. t1
  607. ```
  608. 当前事件账户仅有一个事件名
  609. #### 用户事件总数
  610. ```bash
  611. :bin$ ./jdchain-cli.sh query user-events-count -h
  612. Query user events count.
  613. Usage: jdchain-cli query user-events-count [-hV] [--pretty] --address=<address>
  614. [--gw-host=<gwHost>] [--gw-port=<gwPort>] [--home=<path>] --name=<name>
  615. --address=<address> Event account address
  616. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  617. --gw-port=<gwPort> Set the gateway port. Default: 8080
  618. -h, --help Show this help message and exit.
  619. --home=<path> Set the home directory.
  620. --name=<name> Event name
  621. --pretty Pretty json print
  622. -V, --version Print version information and exit.
  623. ```
  624. - `address`,事件账户地址
  625. - `name`,事件名
  626. 查询事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`事件名`t1`中事件总数:
  627. ```bash
  628. :bin$ ./jdchain-cli.sh query user-events-count --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --name t1
  629. select ledger, input the index:
  630. INDEX LEDGER
  631. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  632. > 0
  633. 1
  634. ```
  635. 当前事件名仅有一个事件
  636. #### 用户事件列表
  637. ```bash
  638. :bin$ ./jdchain-cli.sh query user-events -h
  639. Query user events.
  640. Usage: jdchain-cli query user-events [-hV] [--pretty] --address=<address>
  641. --count=<count> [--gw-host=<gwHost>]
  642. [--gw-port=<gwPort>] [--home=<path>]
  643. --index=<index> --name=<name>
  644. --address=<address> Event account address
  645. --count=<count> Event name item count
  646. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  647. --gw-port=<gwPort> Set the gateway port. Default: 8080
  648. -h, --help Show this help message and exit.
  649. --home=<path> Set the home directory.
  650. --index=<index> Event name item index
  651. --name=<name> Event name
  652. --pretty Pretty json print
  653. -V, --version Print version information and exit.
  654. ```
  655. - `address`,事件账户地址
  656. - `name`,事件名
  657. - `index`,起始位置
  658. - `count`,最大返回
  659. 分页查询用户事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`事件名`t1`中事件,从第`0`个开始,最大返回`10`条:
  660. ```bash
  661. :bin$ ./jdchain-cli.sh query user-events --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --name t1 --index 0 --count 10
  662. select ledger, input the index:
  663. INDEX LEDGER
  664. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  665. > 0
  666. {"blockHeight":12,"content":{"bytes":"YzE=","type":"TEXT"},"contractSource":"","eventAccount":"LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC","name":"t1","sequence":0,"transactionSource":"j5jSszhiJUTbCGtFgxd6uBWyxj56CEHRyhDF6nAnUvJTp7"}
  667. ```
  668. #### 最新用户事件
  669. ```bash
  670. :bin$ ./jdchain-cli.sh query latest-user-event -h
  671. Query latest user event.
  672. Usage: jdchain-cli query latest-user-event [-hV] [--pretty] --address=<address>
  673. [--gw-host=<gwHost>] [--gw-port=<gwPort>] [--home=<path>] --name=<name>
  674. --address=<address> Event account address
  675. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  676. --gw-port=<gwPort> Set the gateway port. Default: 8080
  677. -h, --help Show this help message and exit.
  678. --home=<path> Set the home directory.
  679. --name=<name> Event name
  680. --pretty Pretty json print
  681. -V, --version Print version information and exit.
  682. ```
  683. - `address`,时间账户地址
  684. - `name`,事件名
  685. 查询用户事件账户`LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC`事件名`t1`最新事件:
  686. ```bash
  687. :bin$ ./jdchain-cli.sh query latest-user-event --address LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC --name t1
  688. select ledger, input the index:
  689. INDEX LEDGER
  690. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  691. > 0
  692. {"blockHeight":12,"content":{"bytes":"YzE=","type":"TEXT"},"contractSource":"","eventAccount":"LdeNwQWabrf6WSjZ35saFo52MfQFhVKvm11aC","name":"t1","sequence":0,"transactionSource":"j5jSszhiJUTbCGtFgxd6uBWyxj56CEHRyhDF6nAnUvJTp7"}
  693. ```
  694. #### 合约总数
  695. 查询合约总数:
  696. ```bash
  697. :bin$ ./jdchain-cli.sh query contracts-count
  698. select ledger, input the index:
  699. INDEX LEDGER
  700. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  701. > 0
  702. 1
  703. ```
  704. 当前账本仅有一个合约
  705. #### 合约列表
  706. ```bash
  707. :bin$ ./jdchain-cli.sh query contracts -h
  708. Query contracts.
  709. Usage: jdchain-cli query contracts [-hV] [--pretty] --count=<count>
  710. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  711. [--home=<path>] --index=<index>
  712. --count=<count> Contract item count
  713. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  714. --gw-port=<gwPort> Set the gateway port. Default: 8080
  715. -h, --help Show this help message and exit.
  716. --home=<path> Set the home directory.
  717. --index=<index> Contract item index
  718. --pretty Pretty json print
  719. -V, --version Print version information and exit.
  720. ```
  721. - `index`,起始位置
  722. - `count`,最大返回
  723. 分页查询合约,从第`0`个开始,最大返回`10`条:
  724. ```bash
  725. :bin$ ./jdchain-cli.sh query contracts --index 0 --count 10
  726. select ledger, input the index:
  727. INDEX LEDGER
  728. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  729. > 0
  730. ADDRESS PUBKEY
  731. LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH 7VeRFZEqSdXWQxaLUFaAgJVdVTssuwQdBg4KPGgCCTbrzqxA
  732. ```
  733. 返回合约地址和公钥信息
  734. #### 合约详情
  735. ```bash
  736. e:bin$ ./jdchain-cli.sh query contract -h
  737. Query contract.
  738. Usage: jdchain-cli query contract [-hV] [--pretty] --address=<address>
  739. [--gw-host=<gwHost>] [--gw-port=<gwPort>]
  740. [--home=<path>]
  741. --address=<address> Contract address
  742. --gw-host=<gwHost> Set the gateway host. Default: 127.0.0.1
  743. --gw-port=<gwPort> Set the gateway port. Default: 8080
  744. -h, --help Show this help message and exit.
  745. --home=<path> Set the home directory.
  746. --pretty Pretty json print
  747. -V, --version Print version information and exit.
  748. ```
  749. - `address`,合约地址
  750. 查询合约`LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH`详情:
  751. ```bash
  752. :bin$ ./jdchain-cli.sh query contract --address LdeNyF6jdNry5iCqmHdAFTQPvC8UkbJ9avoXH
  753. select ledger, input the index:
  754. INDEX LEDGER
  755. 0 j5sB3sVTFgTqTYzo7KtQjBLSy8YQGPpJpvQZaW9Eqk46dg
  756. > 0
  757. package com.jdchain.samples.contract;
  758. import com.jd.blockchain.contract.*;
  759. import utils.*;
  760. import com.jd.blockchain.crypto.*;
  761. import com.jd.blockchain.ledger.*;
  762. public class SampleContractImpl implements EventProcessingAware, SampleContract
  763. {
  764. private ContractEventContext eventContext;
  765. public void setKVWithVersion(final String address, final String key, final String value, final long version) {
  766. this.eventContext.getLedger().dataAccount(Bytes.fromBase58(address)).setText(key, value, version);
  767. }
  768. public void setKV(final String address, final String key, final String value) {
  769. final TypedKVEntry[] entries = this.eventContext.getUncommittedLedger().getDataEntries(address, new String[] { key });
  770. long version = -1L;
  771. if (null != entries && entries.length > 0) {
  772. version = entries[0].getVersion();
  773. }
  774. this.eventContext.getLedger().dataAccount(Bytes.fromBase58(address)).setText(key, value, version);
  775. }
  776. public String registerUser(final String seed) {
  777. final CryptoAlgorithm algorithm = Crypto.getAlgorithm("ed25519");
  778. final SignatureFunction signFunc = Crypto.getSignatureFunction(algorithm);
  779. final AsymmetricKeypair cryptoKeyPair = signFunc.generateKeypair(seed.getBytes());
  780. final BlockchainKeypair keypair = new BlockchainKeypair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey());
  781. this.eventContext.getLedger().users().register(keypair.getIdentity());
  782. return keypair.getAddress().toBase58();
  783. }
  784. public String registerDataAccount(final String seed) {
  785. final CryptoAlgorithm algorithm = Crypto.getAlgorithm("ed25519");
  786. final SignatureFunction signFunc = Crypto.getSignatureFunction(algorithm);
  787. final AsymmetricKeypair cryptoKeyPair = signFunc.generateKeypair(seed.getBytes());
  788. final BlockchainKeypair keypair = new BlockchainKeypair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey());
  789. this.eventContext.getLedger().dataAccounts().register(keypair.getIdentity());
  790. return keypair.getAddress().toBase58();
  791. }
  792. public String registerEventAccount(final String seed) {
  793. final CryptoAlgorithm algorithm = Crypto.getAlgorithm("ed25519");
  794. final SignatureFunction signFunc = Crypto.getSignatureFunction(algorithm);
  795. final AsymmetricKeypair cryptoKeyPair = signFunc.generateKeypair(seed.getBytes());
  796. final BlockchainKeypair keypair = new BlockchainKeypair(cryptoKeyPair.getPubKey(), cryptoKeyPair.getPrivKey());
  797. this.eventContext.getLedger().eventAccounts().register(keypair.getIdentity());
  798. return keypair.getAddress().toBase58();
  799. }
  800. public void publishEventWithSequence(final String address, final String topic, final String content, final long sequence) {
  801. this.eventContext.getLedger().eventAccount(Bytes.fromBase58(address)).publish(topic, content, sequence);
  802. }
  803. public void publishEvent(final String address, final String topic, final String content) {
  804. final Event event = this.eventContext.getUncommittedLedger().getLatestEvent(address, topic);
  805. long sequence = -1L;
  806. if (null != event) {
  807. sequence = event.getSequence();
  808. }
  809. this.eventContext.getLedger().eventAccount(Bytes.fromBase58(address)).publish(topic, content, sequence);
  810. }
  811. public void beforeEvent(final ContractEventContext eventContext) {
  812. this.eventContext = eventContext;
  813. }
  814. public void postEvent(final ContractEventContext eventContext, final Exception error) {
  815. }
  816. }
  817. ```