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