@sqfasd
2016-08-15T18:01:17.000000Z
字数 16425
阅读 4900
post /api/accounts/open2/
var publicKey = AschJS.crypto.getKeys(secret).publicKey;
var address = AschJS.crypto.getAddress(publicKey);
{
publicKey: "768f216d8ce119afc5c5181f9bed1ba81ef88241e322bbb882898aa766acdad3"
}
{
"success": true,
"account": {
"address": "10174159498857769178",
"unconfirmedBalance": 10000000000000000,
"balance": 10000000000000000,
"unconfirmedSignature": false,
"secondSignature": false,
"secondPublicKey": "",
"multisignatures": [],
"u_multisignatures": []
},
"latestBlock": {
"height": 171,
"timestamp": 804390
},
"version": {
"version": "0.9.0",
"build": "development"
}
}
get /api/loader/status/sync
返回后端同步状态
{
"success": true,
"syncing": false, // 是否在同步中,如果为true,目前没有数据可以展示
"blocks": 0,
"height": 92403
}
get /api/delegates/get/?publicKey=a28242b61ee3c0a71da60ea2e1fcd976bb7b3a48e65f5c2487a53707658fcc0b
每10秒调用1次,用来刷新余额
get /api/accounts?address=4205898691220223329L
{
"success": true,
"account": {
"address": "4205898691220223329L",
"unconfirmedBalance": "0",
"balance": "0",
"publicKey": "a28242b61ee3c0a71da60ea2e1fcd976bb7b3a48e65f5c2487a53707658fcc0b",
"unconfirmedSignature": 0,
"secondSignature": 0,
"secondPublicKey": null,
"multisignatures": [ ],
"u_multisignatures": [ ]
}
"latestBlock": {
"height": 171,
"timestamp": 804390
},
"version": {
"version": "0.9.0",
"build": "development"
}
}
get /api/peers/version
{
"success": true,
"version": "0.3.1",
"build": "v12:40:51 29/05/2016
"
}
get /api/transactions?limit=8&orderBy=t_timestamp:desc&recipientId=2323236473289675612L&senderPublicKey=58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc
{
"success": true,
"transactions": [
{
"id": "10616007179419450740",
"height": 20548,
"blockId": "7174726601767749312",
"type": 0,
"timestamp": 239838,
"senderPublicKey": "58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc",
"senderId": "2323236473289675612L",
"recipientId": "3347762178747334519L",
"amount": 549300000000, // 除以100000000
"fee": 10000000,
"signature": "bed865e8b593e9109bfa60b1a589043d536a93c46f8bb93b309392cea5d4d2c0aca95c50612d70885cfdad95c989802a84bbe9ff707c32170205527d19fa5b08",
"signatures": null,
"confirmations": 71996,
"asset": { }
},
{
"id": "16625620042597159980",
"height": 13477,
"blockId": "3486821525010364648",
"type": 0,
"timestamp": 166778,
"senderPublicKey": "58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc",
"senderId": "2323236473289675612L",
"recipientId": "10452770844182433280L",
"amount": 1098000000000,
"fee": 10000000,
"signature": "268d27798d0a8ac23aa202c2a5f65fa50cdf816c852ff905bbfe5d3c1fa236999f35d0023583009d9d5b51439b20bbc39fa0d61cd01a98b6296b6aa0d4b69d0b",
"signatures": null,
"confirmations": 79067,
"asset": { }
},
{
"id": "11018573656857334946",
"height": 13327,
"blockId": "5385410072843310737",
"type": 0,
"timestamp": 165185,
"senderPublicKey": "58d55f95d6383d526a150e69c767c9eb78b2dd6ebe55837cbb133319a3d7c5bc",
"senderId": "2323236473289675612L",
"recipientId": "10452770844182433280L",
"amount": 5490600000000,
"fee": 10000000,
"signature": "7974385399ef50fbffe811f9db78f7ae0d2134fbbe880a8e4c04d4cf42161b471d19ee67d64289e738835420219bcafbfbd4b304daebbea1d6fdeebb3669ae03",
"signatures": null,
"confirmations": 79217,
"asset": { }
},
{
"id": "6464159134897078303",
"height": 1,
"blockId": "13658550407518916215",
"type": 0,
"timestamp": 0,
"senderPublicKey": "d121d3abf5425fdc0f161d9ddb32f89b7750b4bdb0bff7d18b191d4b4bafa6d4",
"senderId": "6566229458323231555L",
"recipientId": "2323236473289675612L",
"amount": 7137999103029,
"fee": 0,
"signature": "860600cffa7160916f4e66c3749db01778007ccb0ffe8f8b3f70aa62cb886cedaef4f8d2c55e090c41dbf38894afcd38bcd08dc267f52e4368eb4369c7a8d10f",
"signatures": null,
"confirmations": 92543,
"asset": { }
}
],
"count": "4"
}
get /api/blocks/?limit=25&offset=0&orderBy=height:desc
{
"success": true,
"count": 92712,
"blocks": [
{
"id": "13692206355581061757",
"version": 0,
"timestamp": 1003680,
"height": 92698,
"previousBlock": "6044206022367095159",
"numberOfTransactions": 0, // 交易数
"totalAmount": 0, // 金额
"totalFee": 0, // 手续费
"reward": 0, // 奖励
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "c379455ea222666817e8b6d7673fb47f3594ab0516441efbcf93c0ab0d9ab15f",
"generatorId": "3779220164400008665L",
"blockSignature": "0004890452e44395613e9a2706d4900212b0ff16566c74a0542934a47ad7c40e896a3864a53682962bca42eb05ecd8865f58d0deadca16fa27c5006661d7ac02",
"confirmations": 15,
"totalForged": "0"
},
{
"id": "6044206022367095159",
"version": 0,
"timestamp": 1003670,
"height": 92697,
"previousBlock": "3152463308142374880",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "9bb219513cfdcf75d096e46ec338732bf78f1453c1c9e949fb14590bccdee31c",
"generatorId": "2929352591538931341L",
"blockSignature": "e762e30fee19d2d8732bc6c05509adebadfa9b16c3800c13993c9cd108f6815b0eacbf10ddcc956135c272c5ad06a8f04bef03ae35f850b46df9c3311594260c",
"confirmations": 16,
"totalForged": "0"
},
{
"id": "3152463308142374880",
"version": 0,
"timestamp": 1003660,
"height": 92696,
"previousBlock": "8632427688777925267",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "54cd463ad4769270c2057dbc8ad2512452882631c952531dad09ae79b4b78fc1",
"generatorId": "224890727516907614L",
"blockSignature": "b30ef3c9a849e32d09ef95091facd77fbce9b36e50e90d1fe2239cde8dee3f73ff1e9f2cb0b04bbd98a7f9a3f9cf1c777e6feeda474db2e1e3c5cd9702fd2c09",
"confirmations": 17,
"totalForged": "0"
},
{
"id": "8632427688777925267",
"version": 0,
"timestamp": 1003650,
"height": 92695,
"previousBlock": "17794243511699351932",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "b0968d8fd6ab885b1df6ec2af2cacc87c8ee56a3429d39064a69f59a7533a5ad",
"generatorId": "14859452201629254180L",
"blockSignature": "cbd905ba61b80fc2056c2560c16b938455972a5b7e21f4c99bca2f9503d4fcb10d7fe4a184da650908010cf60f0377f8fb6915243b8f4e733934de8bc5650909",
"confirmations": 18,
"totalForged": "0"
},
{
"id": "17794243511699351932",
"version": 0,
"timestamp": 1003640,
"height": 92694,
"previousBlock": "6780906364076998282",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "a21f655cf396727c186254f23d9f266481884442f6338a9d55f603a7abbdcb61",
"generatorId": "14588841135802281548L",
"blockSignature": "17e089f5dbcb33af286d0b17abf5175e774cb0684941f4e1d5d8be45d7511713befb5bd6ddddf33b3250f0379ba93c8707cdb0ed264baddf6b7f00371b8a2101",
"confirmations": 19,
"totalForged": "0"
},
{
"id": "6780906364076998282",
"version": 0,
"timestamp": 1003630,
"height": 92693,
"previousBlock": "9642770619142318665",
"numberOfTransactions": 1,
"totalAmount": 66600000000,
"totalFee": 10000000,
"reward": 0,
"payloadLength": 117,
"payloadHash": "48319c19202b81e186c0fddcfd1308fbd87777b840b8067582f130dc58e91d02",
"generatorPublicKey": "0c7c2b612db9cccba57583e962bb609ea67838f8616546ce946eaf40bf73a2da",
"generatorId": "17027481066703298407L",
"blockSignature": "8145b116a0f3036205e652e40f3854e9dc507acd4fef109e2fd4d00e99d719e1809b237bc1e54b26b722534f68155d17030cf0888f96a1731d2c4309c9af150c",
"confirmations": 20,
"totalForged": "10000000"
},
{
"id": "9642770619142318665",
"version": 0,
"timestamp": 1003620,
"height": 92692,
"previousBlock": "13368564270730619667",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "9548a003ec975142d99e0e9a720655b4be0a08801f940dc0fbc242de2ecd5558",
"generatorId": "13883760527284121296L",
"blockSignature": "7be6c489fb0e200df779a05970938a1a1a0aeda58c851d5d24417f66c2edf0e266fdb88915e68584c896008960ad3e49ab8f8e84dbe02fe0a13bb371df74f604",
"confirmations": 21,
"totalForged": "0"
},
{
"id": "13368564270730619667",
"version": 0,
"timestamp": 1003610,
"height": 92691,
"previousBlock": "4583638198773929113",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "2f872264534a1722e136bddf29a301fa97708f88583130770d54c1d11366e5fc",
"generatorId": "9926064757911337096L",
"blockSignature": "4f90f50bfc410da0fd72cfac348ecd36149724bfba6c741673c207e671d26570908f123a2d3c748da1ae0a8296727cfdbd7d7ef7cbe9678b6b2750f3a9a30101",
"confirmations": 22,
"totalForged": "0"
},
{
"id": "4583638198773929113",
"version": 0,
"timestamp": 1003600,
"height": 92690,
"previousBlock": "4766628090642248754",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "95f0cc8ee70052aa78866ec0be9146917d05a05db814b2c4d4ed151b4e5e6f7b",
"generatorId": "14425521180678845484L",
"blockSignature": "b86f6819165b5c2fd83afd3f4cce03779b130e6745a5ec6a58434b4b9025000c1874e44ba342ac2b735e038f787d8d70fe073e1efcd62f7aeb7100dd197fc100",
"confirmations": 23,
"totalForged": "0"
}
]
}
get /api/transactions/?blockId=17268131061983930289
{
"success": true,
"transactions": [
{
"id": "2716730522464841952",
"height": 92898,
"blockId": "17268131061983930289",
"type": 0,
"timestamp": 1005680,
"senderPublicKey": "8bb89840b902ed812da1c6a7e732de152544ae9c1ac2e8cc291d97730fe8f3ef",
"senderId": "5500617461256760551L",
"recipientId": "13805841947687830643L",
"amount": 4980000000,
"fee": 10000000,
"signature": "e52602799bf2c8234b09852c367ae3da478ba5055579bc9e3fe9d8165e95132b39d64fb70181c3a5bbb54d2025d1de0453a1f783f8dc3aba351c227b41e9d50a",
"signatures": null,
"confirmations": 1,
"asset": { }
}
],
"count": "1"
}
get /api/delegates/?limit=101&offset=0&orderBy=rate:asc&address=17110047919889272525L
{
"success": true,
"delegates": [
{
"username": "genesis_60",
"address": "17110047919889272525L",
"publicKey": "0186d6cbee0c9b1a9783e7202f57fc234b1d98197ada1cc29cfbdf697a636ef1",
"vote": 9999989590000000,
"producedblocks": 186,
"missedblocks": 0,
"rate": 1,
"approval": "100.00",
"productivity": "100.00",
"voted": true
},
{
"username": "genesis_77",
"address": "11004588490103196952L",
"publicKey": "031e27beab583e2c94cb3167d128fc1a356c1ae88adfcfaa2334abffa3ae0b4c",
"vote": 9999989590000000,
"producedblocks": 187,
"missedblocks": 0,
"rate": 2,
"approval": "100.00",
"productivity": "100.00"
},
{
"username": "genesis_79",
"address": "11506830473925742632L",
"publicKey": "03e811dda4f51323ac712cd12299410830d655ddffb104f2c9974d90bf8c583a",
"vote": 9999989590000000,
"producedblocks": 188,
"missedblocks": 0,
"rate": 3,
"approval": "100.00",
"productivity": "100.00"
},
{
"username": "genesis_91",
"address": "5179180534922237219L",
"publicKey": "0779ca873bbda77f2850965c8a3a3d40a6ee4ec56af55f0a3f16c7c34c0f298b",
"vote": 9999989590000000,
"producedblocks": 184,
"missedblocks": 0,
"rate": 4,
"approval": "100.00",
"productivity": "100.00"
}
],
"totalCount": 102
}
get /api/accounts/delegates/?address=11845914371838695861L
{
"success": true,
"delegates": [
{
"username": "genesis_60",
"address": "17110047919889272525L",
"publicKey": "0186d6cbee0c9b1a9783e7202f57fc234b1d98197ada1cc29cfbdf697a636ef1",
"vote": 9999989590000000,
"producedblocks": 186,
"missedblocks": 0,
"rate": 1,
"approval": "100.00",
"productivity": "100.00"
},
{
"username": "genesis_77",
"address": "11004588490103196952L",
"publicKey": "031e27beab583e2c94cb3167d128fc1a356c1ae88adfcfaa2334abffa3ae0b4c",
"vote": 9999989590000000,
"producedblocks": 187,
"missedblocks": 0,
"rate": 2,
"approval": "100.00",
"productivity": "100.00"
},
{
"username": "genesis_79",
"address": "11506830473925742632L",
"publicKey": "03e811dda4f51323ac712cd12299410830d655ddffb104f2c9974d90bf8c583a",
"vote": 9999989590000000,
"producedblocks": 188,
"missedblocks": 0,
"rate": 3,
"approval": "100.00",
"productivity": "100.00"
}
]
}
get /api/blocks/?generatorPublicKey=4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5&limit=25&offset=0&orderBy=height:desc
{
"success": true,
"blocks": [
{
"id": "7404786028080528531",
"version": 0,
"timestamp": 1881510,
"height": 18549,
"previousBlock": "4390936161708856388",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
"generatorId": "15685993315437640088L",
"blockSignature": "e61d789268fef92513e953d98a2a9aa18a1ccc79a3417ad7074ac72e1aa10906493879eb01a105848e191a47fa7718789ad529b62c90dfde0276a4ef6a171d08",
"confirmations": "28",
"totalForged": 0
},
{
"id": "4438138750361572959",
"version": 0,
"timestamp": 1879910,
"height": 18391,
"previousBlock": "4018980595601805710",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
"generatorId": "15685993315437640088L",
"blockSignature": "c861cf5b18112070a4d3d374e2e98347bb957bf7c45cd6d0f030c939953fbf93cb2cc9a40088b09b5c5179a6b45c45cfeedc877c30c44649f87661b3c1f6f909",
"confirmations": "186",
"totalForged": 0
},
{
"id": "10930613875917053385",
"version": 0,
"timestamp": 1878870,
"height": 18288,
"previousBlock": "15993928202332132995",
"numberOfTransactions": 0,
"totalAmount": 0,
"totalFee": 0,
"reward": 0,
"payloadLength": 0,
"payloadHash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
"generatorPublicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
"generatorId": "15685993315437640088L",
"blockSignature": "10a77dcdbf05d4f69e97c5232142cb26621a2694397eb6e1afc90d19ea87d45ef459dc150a86582274a6445c94a13840d92d1feccc733832de3c14f59e9a4804",
"confirmations": "289",
"totalForged": 0
}
],
"count": 185
}
get /api/delegates/get/?publicKey=4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5
{
"success": true,
"delegate": {
"username": "genesis_5",
"address": "15685993315437640088L",
"publicKey": "4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5",
"vote": 8949999780000000,
"producedblocks": 185,
"missedblocks": 0,
"rate": 28,
"approval": "89.50",
"productivity": "100.00",
"fees": 10,
"rewards": 20,
"forged": 30
}
}
asch系统的所有写操作都是通过发起一个交易来完成的。
交易数据通过一个叫做asch-js的库来创建,然后再通过一个POST接口发布出去
POST接口规格如下:
/peer/transactions
库安装
npm install asch-js
var asch = require('asch-js');
var transaction = asch.signature.createSignature(password, secondPassword);
POST(transaction);
var asch = require('asch-js');
var targetAddress = "15685993315437640088L";
var amount = 100;
var password = 'first password';
var secondPassword =user.secondPassword || undefined;
// 其中password是在用户登录的时候记录下来的,secondPassword需要每次让用户输入
// 可以通过user.secondPublicKey 来判断用户是否有二级密码,如果没有,则不必输入,以下几个交易类型类似
var transaction = asch.transaction.createTransaction(targetAddress, amount, password, secondPassword);
POST(transaction);
var asch = require('asch-js');
var transaction = asch.delegate.createDelegate(password, userName, user.secondPassword || undefined);
POST(transaction);
var asch = require('asch-js');
// 投票内容是一个列表,列表中的每一个元素是一个符号加上所选择的受托人的公钥,符号为+表示投票,符号为-表示取消投票
var voteContent = [
'+4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5',
'-0186d6cbee0c9b1a9783e7202f57fc234b1d98197ada1cc29cfbdf697a636ef1'
];
var transaction = asch.vote.createVote(password, voteContent, secondPassword || undefined);
POST(transaction);
...
get /api/delegates/voters/?publicKey=4fe5cd087a319956ddc05725651e56486961b7d5733ecd23e26e463bf9253bb5
{
"success": true,
"accounts": [
{
"address": "18221003081100215902",
"publicKey": "1418e0fdf902d42dfb40e41948bad2917ecd01f467b3b1cd2729a6ea93dd238e",
"balance": 39700000000
},
{
"address": "14333823283272251370",
"publicKey": "48452f62ce523bb6c25d2e43f2961da28f0339653a443a155c2d7cf151347cba",
"balance": 9988800000000
},
{
"address": "12999975986535915958",
"publicKey": "fa1a07d8a7b67f08bb0f6d6f72786f2d48066af896708d9c9d7f105d3bd9006c",
"balance": 19585449406073
},
{
"address": "13411347185948980398",
"publicKey": "1448c71b7cf9a040edcd4e898bafba6c8e95ac1ad6c6394dde08ead3d305e9ce",
"balance": 449998750000000
},
{
"address": "17414118636859014500",
"publicKey": "15424fffc29043c810dce1593c1238733bc09979a0a31cd4ec3c33fb9076ca19",
"balance": 3981062360111112
}
]
}
get /api/peers?limit=20&offset=0
{
"success": true,
"peers": [
{
"ip": "45.32.19.241",
"port": 4096,
"state": 2,
"os": "linux3.13.0-87-generic",
"version": "0.9.1"
},
{
"ip": "45.32.62.184",
"port": 4096,
"state": 2,
"os": "linux3.13.0-87-generic",
"version": "0.9.1"
}
]
}