DIY: Redeem your Steem reward automatically with a simple JavaScript bot 🇺🇸 🇮🇹 [ EN / ITA ]
As a software developer, I always think: "If I you repeat it, You should automate it!". I understand that clicking to get the reward is part of Steemit gamification, but I have I little free time so I prefere to use it in a better and more productive way.
Maybe there's already a Steemit service that does it, but I'm always scaried to give my private keys to a third part.
Come svilupatore software, penso sempre: "Se devi riperlo, dovresti automatizzarlo!" Capisco che cliccare per ricevere il compenso fa parte della gamification di Steemit, ma visto che ho poco tempo preferirei utilizzarlo al meglio e in modo più produttivo :D
Magari c'é già qualche servizio per Steemit che lo fa, ma sono sempre dubbioso sul dare le mie chiavi private a terzi.
Requirements / Requisiti
- NodeJS, babel-node, npx, steemjs
- 1 always-on computer (aka server)
// author @luigi-tecnologo run it with: npx babel-node claim.js
import steem from 'steem';
const username = 'YOURSTEEMNAME';
const password = 'YOURWIFPASSWORD';
const wif = steem.auth.toWif(username, password, 'posting');
async function sleep(mills) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve();
}, mills);
});
}
async function main() {
try {
const res = await steem.api.getAccounts([username]);
const reward = res[0];
console.log('@@@ Status', reward.reward_steem_balance, reward.reward_sbd_balance, reward.reward_vesting_balance);
if (parseFloat(reward.reward_steem_balance) > 0 ||
parseFloat(reward.reward_sbd_balance) > 0 ||
parseFloat(reward.reward_vesting_balance) > 0) {
const res2 = await steem.broadcast.claimRewardBalance(wif, username, reward.reward_steem_balance, reward.reward_sbd_balance, reward.reward_vesting_balance);
console.log('@@@ Reward', reward.reward_steem_balance, reward.reward_sbd_balance, reward.reward_vesting_balance);
console.log('REWARDED');
}
} catch (error) {
console.error('ERR:', error);
}
}
// main
(async function () {
while (true) {
await main();
await sleep(900 * 1000); // every 15mins
}
// never here
})();
It would be safer to use the posting key directly, instead of fetching it using the password, which exposes it unnecessarily. Use the password ONLY if you have to, otherwise secure in cold storage and use the appropriate keys for your different tasks.
Change to
const wif = 'YOURPOSTINGKEY';
Sure, i used the full password because i run it on my encrypted server and i also use it for other features
I was editing my comment while you replied. Check the my updated comment 🙂
I don't think the password is sent remotely to get the posting key,.. But sure it's better to use the lower priviledge
Not at all, the password is used to derive the keys each time there's an operation. Private keys are never sent to any servers, they only sign the transactions locally. The risky part is, if you get hacked and the hacker gets your master password from your .js scripts, they can do a lot of damage. That's why it's recommended to never use the master password other than in extreme cases (account recovery, changing the key set).
I fact, the
auth
operations are done offline, you can check that with only two lines:Nah, preferisco usare il dito, voglio vedere i big money che si trasferiscono nel mio profilo in diretta.😂😂
Ah dimenticavo, bel lavoro!
Grazie. Ognuno è libero di avere le sue perversioni :D Personalmente preferisco far fare il "lavoro sporco" ai bot e guardarli che lavorano per me :P
ahahah bello anche questo
img credz: pixabay.com
Nice, you got a 97.0% @tincho upgoat, thanks to @luigi-tecnologo
It consists of $2.12 vote and $0.12 curation
Want a boost? Minnowbooster's got your back!
The @OriginalWorks bot has determined this post by @luigi-tecnologo to be original material and upvoted(1.5%) it!
To call @OriginalWorks, simply reply to any post with @originalworks or !originalworks in your message!
Congratulations @luigi-tecnologo! You have completed some achievement on Steemit and have been rewarded with new badge(s) :
Award for the number of comments
Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here
If you no longer want to receive notifications, reply to this comment with the word
STOP