I've been doing it a little differently. Here's a helper function that I wrote in order to parse the account history of any given account, but only output the "transfer" transactions. The general idea is the same, but here it is so folks can see a concrete example of a test. In this case parsing out only transactions:
let steem = require('steem');
steem.api.setOptions({ url: 'https://api.steemit.com' });
function getAllAccountTransactions( username ){
steem.api.getAccountHistory(username, -1, 0, (err, result) => {
limit = result[0][0];
while(limit >= 0){
steem.api.getAccountHistory(username, limit, 100, (err, result) => {
result.map((r) => {
r[1].op[0] == 'transfer' ? console.log(r[1]) : '' ;
});
});
limit -= 101;
}
});
}
process.on('unhandledRejection', (reason, p) => {
});
getAllAccountTransactions('sha256md5');
That's a good approach. Thank you for posting a concrete example.
One difference is that I have used
.reverse()
to maintain a consistent descending order. This is important if you want to stop the search based on finding a particular kind of transaction.Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit