EOS節點get_actions api更新
1:請求參數未變化
2:返回值變動
新結構,比原來多了query_time,eos4j的需要改源碼,也可以手動發送自己按照下面結構封裝一個DTO,第一個找到能用的節點:https://api.eossweden.se/v1/history/get_actions
上面接口返回值不全
參考新節點:https://eos.greymass.com/v1/history/get_actions
參數變爲升序,返回值外層少一個數據
請求參數:
{
"pos": 0, //最新條
"offset": 1, //每次從最新的到歷史個數
"account_name": "yujianeos123"
}
{
"query_time": 84,
"last_irreversible_block": 89759808,
"actions": [
{
"account_action_seq": 0,
"global_action_seq": 9438784039,
"block_num": 83948681,
"block_time": "2019-10-11T07:52:10.500",
"action_trace": {
"act": {
"account": "eosio.token",
"name": "transfer",
"authorization": [
{
"actor": "vuniyuoxoeub",
"permission": "active"
}
],
"data": {
"from": "vuniyuoxoeub",
"to": "yujianeos123",
"memo": "1122233",
"quantity": "1.1874 EOS"
},
"hex_data": "7b2266726f6d223a2276756e6979756f786f657562222c22746f223a2279756a69616e656f73313233222c226d656d6f223a2231313232323333222c227175616e74697479223a22312e3138373420454f53227d"
},
"trx_id": "1b059e89aa99c39d2d345091b777d512b51a2aa9cb219e7f77288a6bb5a968d8",
"block_num": 83948681,
"block_time": "2019-10-11T07:52:10.500"
}
},
{
"account_action_seq": 1,
"global_action_seq": 9439762571,
"block_num": 83956946,
"block_time": "2019-10-11T09:01:03.500",
"action_trace": {
"act": {
"account": "eosio.token",
"name": "transfer",
"authorization": [
{
"actor": "yujianeos123",
"permission": "active"
}
],
"data": {
"from": "yujianeos123",
"to": "huobideposit",
"memo": "4064697",
"quantity": "1 EOS"
},
"hex_data": "7b2266726f6d223a2279756a69616e656f73313233222c22746f223a2268756f62696465706f736974222c226d656d6f223a2234303634363937222c227175616e74697479223a223120454f53227d"
},
"trx_id": "8169ec4edacc520df6d6cd02a3d88118cd014bcc396ae738ebf8ea676c6ff9ca",
"block_num": 83956946,
"block_time": "2019-10-11T09:01:03.500"
}
}
]
}
直接附上請求源碼,只需要修改請求部分
RestTemplate restTemplate = new RestTemplate();
JSONObject jsonObject = new JSONObject();
jsonObject.put("pos",0);
jsonObject.put("offset",1);
jsonObject.put("account_name","yujianeos123");
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setContentType(MediaType.APPLICATION_JSON_UTF8);
httpHeaders.set("access-control-allow-origin","*");
HttpEntity httpEntity = new HttpEntity(jsonObject,httpHeaders);
httpHeaders.set("USER-AGENT","Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.86 Safari/537.36");
ResponseEntity<EosDto> eosDtoResponseEntity = restTemplate.postForEntity("https://api.eossweden.se/v1/history/get_actions", httpEntity, EosDto.class);
EosDto body = eosDtoResponseEntity.getBody();
for (EosDto.InnerEos innerEos : body.getActions()) {
ActionTrace action_trace = innerEos.getAction_trace();
System.out.println(JSON.toJSONString(action_trace));
}