My Scripts 4- Your Curation Reward In The Past 24 Hours
This script here is being used by a few bots, for different reasons. But if you want to know how much you've made in the last 24 hours in curation rewards, you can use the following code.
```js
let hive = require('@hiveio/hive-js')
var moment = require("moment")
var curation_transactions = []
getDayCurationReward("rishi556", (cb) => {
console.log(cb)
})
function getDayCurationReward(account, callback) {
loadCuration(account, (cb) => {
hive.api.getDynamicGlobalProperties((err, properties) => {
var total_vesting_shares = properties.total_vesting_shares
var total_vesting_fund = properties.total_vesting_fund_steem
var total = 0
for (i in cb) {
total += cb[i]
}
var totalRewards = hive.formatter.vestToHive(total, total_vesting_shares, total_vesting_fund) //Since we have dealt with everything in VESTS so far, we need to convert to HIVE
callback(totalRewards)
})
})
}
function loadCuration(account, callback) {
curation_transactions = []
getTransactions(account, -1, callback)
}
function getTransactions(account, start, callback) {
var last_trans = start
var con = true
hive.api.getAccountHistory(account, start, (start < 0) ? 10000 : Math.min(start, 10000), (err, result) => { //account, start, limit. The limit cannot be greater than start
if (err) {
console.log(err)
setTimeout(() => {
getTransactions(account, last_trans, callback)
}, 1000 * 30) //With account history and public nodes, most likely reason for error is too many requests, so we set a delay of 30 seconds to delay it
return
}
result.reverse() //We get data back with oldest events being first, we want newest events being first so we can work backwards. To achieve that, we reverse the array we get
for (i in result) {
var trans = result[i]
var transTime = moment.utc(trans[1].timestamp).unix()
var now = moment.utc().unix()
if ((now - transTime > 86400)) {
con = false
break
}
var op = trans[1].op
if (op[0] == 'curation_reward') { //All curation reward operations are labeled as curation_reward
curation_transactions.push(parseFloat(op[1].reward.split(" "))) //We push all curation earned
}
last_trans = trans[0] //For going onto the next time around
}
if (con) {
getTransactions(account, last_trans, callback) //Due to limit of 10k, we might need to call it multiple times
} else {
callback(curation_transactions)
}
})
}
```
The base of this was from @yabapmatt's Post Promoter's delegator's fetching script, with some modifications to get curation rewards rather than the current delegation onto accounts. This can also be used to get the history for longer period of times(including all time) with some slight modifications to the difference (86400 * DAYS) or by removing that part in its entirety and adding check to see if the end of the array has been reached and there's no more.
#### History Of Scripts Send From One Account To Multiple Others Auto Send From Multiple To One Destination Witness Rank And Amount Needed To Rank Up
#### History Of Scripts Send From One Account To Multiple Others Auto Send From Multiple To One Destination Witness Rank And Amount Needed To Rank Up
See: My Scripts 4- Your Curation Reward In The Past 24 Hours by @rishi556