[关闭]
@sqfasd 2016-08-15T18:01:17.000000Z 字数 16425 阅读 4900

asch http interface

1 登录

post /api/accounts/open2/

根据密码生成publicKey

  1. var publicKey = AschJS.crypto.getKeys(secret).publicKey;
  2. var address = AschJS.crypto.getAddress(publicKey);

request

  1. {
  2. publicKey: "768f216d8ce119afc5c5181f9bed1ba81ef88241e322bbb882898aa766acdad3"
  3. }

response

  1. {
  2. "success": true,
  3. "account": {
  4. "address": "10174159498857769178",
  5. "unconfirmedBalance": 10000000000000000,
  6. "balance": 10000000000000000,
  7. "unconfirmedSignature": false,
  8. "secondSignature": false,
  9. "secondPublicKey": "",
  10. "multisignatures": [],
  11. "u_multisignatures": []
  12. },
  13. "latestBlock": {
  14. "height": 171,
  15. "timestamp": 804390
  16. },
  17. "version": {
  18. "version": "0.9.0",
  19. "build": "development"
  20. }
  21. }

2 查看同步信息

get /api/loader/status/sync

功能

返回后端同步状态

response

  1. {
  2. "success": true,
  3. "syncing": false, // 是否在同步中,如果为true,目前没有数据可以展示
  4. "blocks": 0,
  5. "height": 92403
  6. }

3 获取委托人信息

get /api/delegates/get/?publicKey=a28242b61ee3c0a71da60ea2e1fcd976bb7b3a48e65f5c2487a53707658fcc0b

response

4 获取账户信息

每10秒调用1次,用来刷新余额

get /api/accounts?address=4205898691220223329L

response

  1. {
  2. "success": true,
  3. "account": {
  4. "address": "4205898691220223329L",
  5. "unconfirmedBalance": "0",
  6. "balance": "0",
  7. "publicKey": "a28242b61ee3c0a71da60ea2e1fcd976bb7b3a48e65f5c2487a53707658fcc0b",
  8. "unconfirmedSignature": 0,
  9. "secondSignature": 0,
  10. "secondPublicKey": null,
  11. "multisignatures": [ ],
  12. "u_multisignatures": [ ]
  13. }
  14. "latestBlock": {
  15. "height": 171,
  16. "timestamp": 804390
  17. },
  18. "version": {
  19. "version": "0.9.0",
  20. "build": "development"
  21. }
  22. }

5 查询版本信息

get /api/peers/version

response

  1. {
  2. "success": true,
  3. "version": "0.3.1",
  4. "build": "v12:40:51 29/05/2016
  5. "
  6. }

6 获取我的交易

get /api/transactions?limit=8&orderBy=t_timestamp:desc&recipientId=2323236473289675612L&senderPublicKey=58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc

response

  1. {
  2. "success": true,
  3. "transactions": [
  4. {
  5. "id": "10616007179419450740",
  6. "height": 20548,
  7. "blockId": "7174726601767749312",
  8. "type": 0,
  9. "timestamp": 239838,
  10. "senderPublicKey": "58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc",
  11. "senderId": "2323236473289675612L",
  12. "recipientId": "3347762178747334519L",
  13. "amount": 549300000000, // 除以100000000
  14. "fee": 10000000,
  15. "signature": "bed865e8b593e9109bfa60b1a589043d536a93c46f8bb93b309392cea5d4d2c0aca95c50612d70885cfdad95c989802a84bbe9ff707c32170205527d19fa5b08",
  16. "signatures": null,
  17. "confirmations": 71996,
  18. "asset": { }
  19. },
  20. {
  21. "id": "16625620042597159980",
  22. "height": 13477,
  23. "blockId": "3486821525010364648",
  24. "type": 0,
  25. "timestamp": 166778,
  26. "senderPublicKey": "58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc",
  27. "senderId": "2323236473289675612L",
  28. "recipientId": "10452770844182433280L",
  29. "amount": 1098000000000,
  30. "fee": 10000000,
  31. "signature": "268d27798d0a8ac23aa202c2a5f65fa50cdf816c852ff905bbfe5d3c1fa236999f35d0023583009d9d5b51439b20bbc39fa0d61cd01a98b6296b6aa0d4b69d0b",
  32. "signatures": null,
  33. "confirmations": 79067,
  34. "asset": { }
  35. },
  36. {
  37. "id": "11018573656857334946",
  38. "height": 13327,
  39. "blockId": "5385410072843310737",
  40. "type": 0,
  41. "timestamp": 165185,
  42. "senderPublicKey": "58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc",
  43. "senderId": "2323236473289675612L",
  44. "recipientId": "10452770844182433280L",
  45. "amount": 5490600000000,
  46. "fee": 10000000,
  47. "signature": "7974385399ef50fbffe811f9db78f7ae0d2134fbbe880a8e4c04d4cf42161b471d19ee67d64289e738835420219bcafbfbd4b304daebbea1d6fdeebb3669ae03",
  48. "signatures": null,
  49. "confirmations": 79217,
  50. "asset": { }
  51. },
  52. {
  53. "id": "6464159134897078303",
  54. "height": 1,
  55. "blockId": "13658550407518916215",
  56. "type": 0,
  57. "timestamp": 0,
  58. "senderPublicKey": "d121d3abf5425fdc0f161d9ddb32f89b7750b4bdb0bff7d18b191d4b4bafa6d4",
  59. "senderId": "6566229458323231555L",
  60. "recipientId": "2323236473289675612L",
  61. "amount": 7137999103029,
  62. "fee": 0,
  63. "signature": "860600cffa7160916f4e66c3749db01778007ccb0ffe8f8b3f70aa62cb886cedaef4f8d2c55e090c41dbf38894afcd38bcd08dc267f52e4368eb4369c7a8d10f",
  64. "signatures": null,
  65. "confirmations": 92543,
  66. "asset": { }
  67. }
  68. ],
  69. "count": "4"
  70. }

7 获取最新的区块

get /api/blocks/?limit=25&offset=0&orderBy=height:desc

response

  1. {
  2. "success": true,
  3. "count": 92712,
  4. "blocks": [
  5. {
  6. "id": "13692206355581061757",
  7. "version": 0,
  8. "timestamp": 1003680,
  9. "height": 92698,
  10. "previousBlock": "6044206022367095159",
  11. "numberOfTransactions": 0, // 交易数
  12. "totalAmount": 0, // 金额
  13. "totalFee": 0, // 手续费
  14. "reward": 0, // 奖励
  15. "payloadLength": 0,
  16. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  17. "generatorPublicKey": "c379455ea222666817e8b6d7673fb47f3594ab0516441efbcf93c0ab0d9ab15f",
  18. "generatorId": "3779220164400008665L",
  19. "blockSignature": "0004890452e44395613e9a2706d4900212b0ff16566c74a0542934a47ad7c40e896a3864a53682962bca42eb05ecd8865f58d0deadca16fa27c5006661d7ac02",
  20. "confirmations": 15,
  21. "totalForged": "0"
  22. },
  23. {
  24. "id": "6044206022367095159",
  25. "version": 0,
  26. "timestamp": 1003670,
  27. "height": 92697,
  28. "previousBlock": "3152463308142374880",
  29. "numberOfTransactions": 0,
  30. "totalAmount": 0,
  31. "totalFee": 0,
  32. "reward": 0,
  33. "payloadLength": 0,
  34. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  35. "generatorPublicKey": "9bb219513cfdcf75d096e46ec338732bf78f1453c1c9e949fb14590bccdee31c",
  36. "generatorId": "2929352591538931341L",
  37. "blockSignature": "e762e30fee19d2d8732bc6c05509adebadfa9b16c3800c13993c9cd108f6815b0eacbf10ddcc956135c272c5ad06a8f04bef03ae35f850b46df9c3311594260c",
  38. "confirmations": 16,
  39. "totalForged": "0"
  40. },
  41. {
  42. "id": "3152463308142374880",
  43. "version": 0,
  44. "timestamp": 1003660,
  45. "height": 92696,
  46. "previousBlock": "8632427688777925267",
  47. "numberOfTransactions": 0,
  48. "totalAmount": 0,
  49. "totalFee": 0,
  50. "reward": 0,
  51. "payloadLength": 0,
  52. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  53. "generatorPublicKey": "54cd463ad4769270c2057dbc8ad2512452882631c952531dad09ae79b4b78fc1",
  54. "generatorId": "224890727516907614L",
  55. "blockSignature": "b30ef3c9a849e32d09ef95091facd77fbce9b36e50e90d1fe2239cde8dee3f73ff1e9f2cb0b04bbd98a7f9a3f9cf1c777e6feeda474db2e1e3c5cd9702fd2c09",
  56. "confirmations": 17,
  57. "totalForged": "0"
  58. },
  59. {
  60. "id": "8632427688777925267",
  61. "version": 0,
  62. "timestamp": 1003650,
  63. "height": 92695,
  64. "previousBlock": "17794243511699351932",
  65. "numberOfTransactions": 0,
  66. "totalAmount": 0,
  67. "totalFee": 0,
  68. "reward": 0,
  69. "payloadLength": 0,
  70. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  71. "generatorPublicKey": "b0968d8fd6ab885b1df6ec2af2cacc87c8ee56a3429d39064a69f59a7533a5ad",
  72. "generatorId": "14859452201629254180L",
  73. "blockSignature": "cbd905ba61b80fc2056c2560c16b938455972a5b7e21f4c99bca2f9503d4fcb10d7fe4a184da650908010cf60f0377f8fb6915243b8f4e733934de8bc5650909",
  74. "confirmations": 18,
  75. "totalForged": "0"
  76. },
  77. {
  78. "id": "17794243511699351932",
  79. "version": 0,
  80. "timestamp": 1003640,
  81. "height": 92694,
  82. "previousBlock": "6780906364076998282",
  83. "numberOfTransactions": 0,
  84. "totalAmount": 0,
  85. "totalFee": 0,
  86. "reward": 0,
  87. "payloadLength": 0,
  88. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  89. "generatorPublicKey": "a21f655cf396727c186254f23d9f266481884442f6338a9d55f603a7abbdcb61",
  90. "generatorId": "14588841135802281548L",
  91. "blockSignature": "17e089f5dbcb33af286d0b17abf5175e774cb0684941f4e1d5d8be45d7511713befb5bd6ddddf33b3250f0379ba93c8707cdb0ed264baddf6b7f00371b8a2101",
  92. "confirmations": 19,
  93. "totalForged": "0"
  94. },
  95. {
  96. "id": "6780906364076998282",
  97. "version": 0,
  98. "timestamp": 1003630,
  99. "height": 92693,
  100. "previousBlock": "9642770619142318665",
  101. "numberOfTransactions": 1,
  102. "totalAmount": 66600000000,
  103. "totalFee": 10000000,
  104. "reward": 0,
  105. "payloadLength": 117,
  106. "payloadHash": "48319c19202b81e186c0fddcfd1308fbd87777b840b8067582f130dc58e91d02",
  107. "generatorPublicKey": "0c7c2b612db9cccba57583e962bb609ea67838f8616546ce946eaf40bf73a2da",
  108. "generatorId": "17027481066703298407L",
  109. "blockSignature": "8145b116a0f3036205e652e40f3854e9dc507acd4fef109e2fd4d00e99d719e1809b237bc1e54b26b722534f68155d17030cf0888f96a1731d2c4309c9af150c",
  110. "confirmations": 20,
  111. "totalForged": "10000000"
  112. },
  113. {
  114. "id": "9642770619142318665",
  115. "version": 0,
  116. "timestamp": 1003620,
  117. "height": 92692,
  118. "previousBlock": "13368564270730619667",
  119. "numberOfTransactions": 0,
  120. "totalAmount": 0,
  121. "totalFee": 0,
  122. "reward": 0,
  123. "payloadLength": 0,
  124. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  125. "generatorPublicKey": "9548a003ec975142d99e0e9a720655b4be0a08801f940dc0fbc242de2ecd5558",
  126. "generatorId": "13883760527284121296L",
  127. "blockSignature": "7be6c489fb0e200df779a05970938a1a1a0aeda58c851d5d24417f66c2edf0e266fdb88915e68584c896008960ad3e49ab8f8e84dbe02fe0a13bb371df74f604",
  128. "confirmations": 21,
  129. "totalForged": "0"
  130. },
  131. {
  132. "id": "13368564270730619667",
  133. "version": 0,
  134. "timestamp": 1003610,
  135. "height": 92691,
  136. "previousBlock": "4583638198773929113",
  137. "numberOfTransactions": 0,
  138. "totalAmount": 0,
  139. "totalFee": 0,
  140. "reward": 0,
  141. "payloadLength": 0,
  142. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  143. "generatorPublicKey": "2f872264534a1722e136bddf29a301fa97708f88583130770d54c1d11366e5fc",
  144. "generatorId": "9926064757911337096L",
  145. "blockSignature": "4f90f50bfc410da0fd72cfac348ecd36149724bfba6c741673c207e671d26570908f123a2d3c748da1ae0a8296727cfdbd7d7ef7cbe9678b6b2750f3a9a30101",
  146. "confirmations": 22,
  147. "totalForged": "0"
  148. },
  149. {
  150. "id": "4583638198773929113",
  151. "version": 0,
  152. "timestamp": 1003600,
  153. "height": 92690,
  154. "previousBlock": "4766628090642248754",
  155. "numberOfTransactions": 0,
  156. "totalAmount": 0,
  157. "totalFee": 0,
  158. "reward": 0,
  159. "payloadLength": 0,
  160. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  161. "generatorPublicKey": "95f0cc8ee70052aa78866ec0be9146917d05a05db814b2c4d4ed151b4e5e6f7b",
  162. "generatorId": "14425521180678845484L",
  163. "blockSignature": "b86f6819165b5c2fd83afd3f4cce03779b130e6745a5ec6a58434b4b9025000c1874e44ba342ac2b735e038f787d8d70fe073e1efcd62f7aeb7100dd197fc100",
  164. "confirmations": 23,
  165. "totalForged": "0"
  166. }
  167. ]
  168. }

8. 查询一个区块的交易列表

get /api/transactions/?blockId=17268131061983930289

response

  1. {
  2. "success": true,
  3. "transactions": [
  4. {
  5. "id": "2716730522464841952",
  6. "height": 92898,
  7. "blockId": "17268131061983930289",
  8. "type": 0,
  9. "timestamp": 1005680,
  10. "senderPublicKey": "8bb89840b902ed812da1c6a7e732de152544ae9c1ac2e8cc291d97730fe8f3ef",
  11. "senderId": "5500617461256760551L",
  12. "recipientId": "13805841947687830643L",
  13. "amount": 4980000000,
  14. "fee": 10000000,
  15. "signature": "e52602799bf2c8234b09852c367ae3da478ba5055579bc9e3fe9d8165e95132b39d64fb70181c3a5bbb54d2025d1de0453a1f783f8dc3aba351c227b41e9d50a",
  16. "signatures": null,
  17. "confirmations": 1,
  18. "asset": { }
  19. }
  20. ],
  21. "count": "1"
  22. }

9. 获取入围受托人列表

get /api/delegates/?limit=101&offset=0&orderBy=rate:asc&address=17110047919889272525L

response

  1. {
  2. "success": true,
  3. "delegates": [
  4. {
  5. "username": "genesis_60",
  6. "address": "17110047919889272525L",
  7. "publicKey": "0186d6cbee0c9b1a9783e7202f57fc234b1d98197ada1cc29cfbdf697a636ef1",
  8. "vote": 9999989590000000,
  9. "producedblocks": 186,
  10. "missedblocks": 0,
  11. "rate": 1,
  12. "approval": "100.00",
  13. "productivity": "100.00",
  14. "voted": true
  15. },
  16. {
  17. "username": "genesis_77",
  18. "address": "11004588490103196952L",
  19. "publicKey": "031e27beab583e2c94cb3167d128fc1a356c1ae88adfcfaa2334abffa3ae0b4c",
  20. "vote": 9999989590000000,
  21. "producedblocks": 187,
  22. "missedblocks": 0,
  23. "rate": 2,
  24. "approval": "100.00",
  25. "productivity": "100.00"
  26. },
  27. {
  28. "username": "genesis_79",
  29. "address": "11506830473925742632L",
  30. "publicKey": "03e811dda4f51323ac712cd12299410830d655ddffb104f2c9974d90bf8c583a",
  31. "vote": 9999989590000000,
  32. "producedblocks": 188,
  33. "missedblocks": 0,
  34. "rate": 3,
  35. "approval": "100.00",
  36. "productivity": "100.00"
  37. },
  38. {
  39. "username": "genesis_91",
  40. "address": "5179180534922237219L",
  41. "publicKey": "0779ca873bbda77f2850965c8a3a3d40a6ee4ec56af55f0a3f16c7c34c0f298b",
  42. "vote": 9999989590000000,
  43. "producedblocks": 184,
  44. "missedblocks": 0,
  45. "rate": 4,
  46. "approval": "100.00",
  47. "productivity": "100.00"
  48. }
  49. ],
  50. "totalCount": 102
  51. }

10. 获取我的投票列表

get /api/accounts/delegates/?address=11845914371838695861L

response

  1. {
  2. "success": true,
  3. "delegates": [
  4. {
  5. "username": "genesis_60",
  6. "address": "17110047919889272525L",
  7. "publicKey": "0186d6cbee0c9b1a9783e7202f57fc234b1d98197ada1cc29cfbdf697a636ef1",
  8. "vote": 9999989590000000,
  9. "producedblocks": 186,
  10. "missedblocks": 0,
  11. "rate": 1,
  12. "approval": "100.00",
  13. "productivity": "100.00"
  14. },
  15. {
  16. "username": "genesis_77",
  17. "address": "11004588490103196952L",
  18. "publicKey": "031e27beab583e2c94cb3167d128fc1a356c1ae88adfcfaa2334abffa3ae0b4c",
  19. "vote": 9999989590000000,
  20. "producedblocks": 187,
  21. "missedblocks": 0,
  22. "rate": 2,
  23. "approval": "100.00",
  24. "productivity": "100.00"
  25. },
  26. {
  27. "username": "genesis_79",
  28. "address": "11506830473925742632L",
  29. "publicKey": "03e811dda4f51323ac712cd12299410830d655ddffb104f2c9974d90bf8c583a",
  30. "vote": 9999989590000000,
  31. "producedblocks": 188,
  32. "missedblocks": 0,
  33. "rate": 3,
  34. "approval": "100.00",
  35. "productivity": "100.00"
  36. }
  37. ]
  38. }

11. 获取某个受托人锻造的区块列表

get /api/blocks/?generatorPublicKey=4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5&limit=25&offset=0&orderBy=height:desc

response

  1. {
  2. "success": true,
  3. "blocks": [
  4. {
  5. "id": "7404786028080528531",
  6. "version": 0,
  7. "timestamp": 1881510,
  8. "height": 18549,
  9. "previousBlock": "4390936161708856388",
  10. "numberOfTransactions": 0,
  11. "totalAmount": 0,
  12. "totalFee": 0,
  13. "reward": 0,
  14. "payloadLength": 0,
  15. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  16. "generatorPublicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
  17. "generatorId": "15685993315437640088L",
  18. "blockSignature": "e61d789268fef92513e953d98a2a9aa18a1ccc79a3417ad7074ac72e1aa10906493879eb01a105848e191a47fa7718789ad529b62c90dfde0276a4ef6a171d08",
  19. "confirmations": "28",
  20. "totalForged": 0
  21. },
  22. {
  23. "id": "4438138750361572959",
  24. "version": 0,
  25. "timestamp": 1879910,
  26. "height": 18391,
  27. "previousBlock": "4018980595601805710",
  28. "numberOfTransactions": 0,
  29. "totalAmount": 0,
  30. "totalFee": 0,
  31. "reward": 0,
  32. "payloadLength": 0,
  33. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  34. "generatorPublicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
  35. "generatorId": "15685993315437640088L",
  36. "blockSignature": "c861cf5b18112070a4d3d374e2e98347bb957bf7c45cd6d0f030c939953fbf93cb2cc9a40088b09b5c5179a6b45c45cfeedc877c30c44649f87661b3c1f6f909",
  37. "confirmations": "186",
  38. "totalForged": 0
  39. },
  40. {
  41. "id": "10930613875917053385",
  42. "version": 0,
  43. "timestamp": 1878870,
  44. "height": 18288,
  45. "previousBlock": "15993928202332132995",
  46. "numberOfTransactions": 0,
  47. "totalAmount": 0,
  48. "totalFee": 0,
  49. "reward": 0,
  50. "payloadLength": 0,
  51. "payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
  52. "generatorPublicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
  53. "generatorId": "15685993315437640088L",
  54. "blockSignature": "10a77dcdbf05d4f69e97c5232142cb26621a2694397eb6e1afc90d19ea87d45ef459dc150a86582274a6445c94a13840d92d1feccc733832de3c14f59e9a4804",
  55. "confirmations": "289",
  56. "totalForged": 0
  57. }
  58. ],
  59. "count": 185
  60. }

12. 获取某个受托人的信息

get /api/delegates/get/?publicKey=4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5

response

  1. {
  2. "success": true,
  3. "delegate": {
  4. "username": "genesis_5",
  5. "address": "15685993315437640088L",
  6. "publicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
  7. "vote": 8949999780000000,
  8. "producedblocks": 185,
  9. "missedblocks": 0,
  10. "rate": 28,
  11. "approval": "89.50",
  12. "productivity": "100.00",
  13. "fees": 10,
  14. "rewards": 20,
  15. "forged": 30
  16. }
  17. }

13 交易

asch系统的所有写操作都是通过发起一个交易来完成的。
交易数据通过一个叫做asch-js的库来创建,然后再通过一个POST接口发布出去

POST接口规格如下:

  1. url: /peer/transactions
  2. 设置一个header, key为magic,value为43194d2b
  3. payload为asch-js创建出来的交易数据

库安装

  1. npm install asch-js

13.1 二级支付密码

  1. var asch = require('asch-js');
  2. var transaction = asch.signature.createSignature(password, secondPassword);
  3. POST(transaction);

13.2 转账

  1. var asch = require('asch-js');
  2. var targetAddress = "15685993315437640088L";
  3. var amount = 100;
  4. var password = 'first password';
  5. var secondPassword =user.secondPassword || undefined;
  6. // 其中password是在用户登录的时候记录下来的,secondPassword需要每次让用户输入
  7. // 可以通过user.secondPublicKey 来判断用户是否有二级密码,如果没有,则不必输入,以下几个交易类型类似
  8. var transaction = asch.transaction.createTransaction(targetAddress, amount, password, secondPassword);
  9. POST(transaction);

13.3 注册受托人

  1. var asch = require('asch-js');
  2. var transaction = asch.delegate.createDelegate(password, userName, user.secondPassword || undefined);
  3. POST(transaction);

13.4 投票 & 取消投票

  1. var asch = require('asch-js');
  2. // 投票内容是一个列表,列表中的每一个元素是一个符号加上所选择的受托人的公钥,符号为+表示投票,符号为-表示取消投票
  3. var voteContent = [
  4. '+4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5',
  5. '-0186d6cbee0c9b1a9783e7202f57fc234b1d98197ada1cc29cfbdf697a636ef1'
  6. ];
  7. var transaction = asch.vote.createVote(password, voteContent, secondPassword || undefined);
  8. POST(transaction);

13.5 注册应用

  1. ...

14 获取谁投了我的票

get /api/delegates/voters/?publicKey=4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5

response

  1. {
  2. "success": true,
  3. "accounts": [
  4. {
  5. "address": "18221003081100215902",
  6. "publicKey": "1418e0fdf902d42dfb40e41948bad2917ecd01f467b3b1cd2729a6ea93dd238e",
  7. "balance": 39700000000
  8. },
  9. {
  10. "address": "14333823283272251370",
  11. "publicKey": "48452f62ce523bb6c25d2e43f2961da28f0339653a443a155c2d7cf151347cba",
  12. "balance": 9988800000000
  13. },
  14. {
  15. "address": "12999975986535915958",
  16. "publicKey": "fa1a07d8a7b67f08bb0f6d6f72786f2d48066af896708d9c9d7f105d3bd9006c",
  17. "balance": 19585449406073
  18. },
  19. {
  20. "address": "13411347185948980398",
  21. "publicKey": "1448c71b7cf9a040edcd4e898bafba6c8e95ac1ad6c6394dde08ead3d305e9ce",
  22. "balance": 449998750000000
  23. },
  24. {
  25. "address": "17414118636859014500",
  26. "publicKey": "15424fffc29043c810dce1593c1238733bc09979a0a31cd4ec3c33fb9076ca19",
  27. "balance": 3981062360111112
  28. }
  29. ]
  30. }

15 获取节点列表

get /api/peers?limit=20&offset=0

response

  1. {
  2. "success": true,
  3. "peers": [
  4. {
  5. "ip": "45.32.19.241",
  6. "port": 4096,
  7. "state": 2,
  8. "os": "linux3.13.0-87-generic",
  9. "version": "0.9.1"
  10. },
  11. {
  12. "ip": "45.32.62.184",
  13. "port": 4096,
  14. "state": 2,
  15. "os": "linux3.13.0-87-generic",
  16. "version": "0.9.1"
  17. }
  18. ]
  19. }
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注