Blurtopian Development: BLURT Pending Rewards Auto-Claim Bot

in blurtopian •  10 months ago  (edited)


Banner4_Orange_v2.png

In my attempt to study blurtjs, I opted to take on a task by @megadrive in discord's #blurt-curators channel to build a bot that auto-claims pending account rewards.

1. Approach

Before I took on this task, I was in the process of building a cheetah-like bot that checks for plagiarized content. There were issues I encountered when using blurtjs's streamTransactions(), specifically I get Error: HTTP 429: Too Many Requests. With the help of @ericet, I was able to figure out a work-around for this issue by using JS's setInterval() method.

2. Steps

To run the bot locally, you need to have npm installed. There are several tutorials available on the net. The installation I used was the one which came with nodejs. Installation steps are here.

2.1. Installation

Open up a terminal or shell (depending on your OS) and run the following commands:

  1. git clone https://gitlab.com/blurt/openblurt/blurtopian/blurtopian-autoclaim-bot.git
  2. cd blurtopian-autoclaim-bot
  3. npm install

2.2. Bot Configuration

  1. Create an accounts.json file in the project's root directory (or rename accounts.json.example to accounts.json)
  2. Create an account and posting key pairs (these will be the accounts that will be auto-claimed)
{
  "guest1": "5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg",
  "guest2": "5JRaypasxMx1L97ZUX7YuC5Psb5EAbF821kkAGtBj7xCJFQcbLg"
}
  1. (Optional) Create an .env file and add an environment variable CLAIM_INTERVAL to set interval (in minutes) to check for pending claim account balances (default interval is 360 minutes (6 hours))

    1. touch .env (if using bash shell)
    2. nano .env or vi .env
    3. cat .env to check .env's conent
    CLAIM_INTERVAL=360
    

2.3. Run

Running the following command should run the bot.

  1. Run npm start

image.png

2.4. Run Forever

If you have a server (I use Privex), you can opt to run the app perpetually via pm2.

2.4.1. Install pm2

  1. npm install pm2 -g
  2. pm2 startup
  3. Copy the command generated by the previous step
  4. pm2 start npm -- start
  5. pm2 save
  6. pm2 l

Step 6 should output the running npm process. When you logout and re-login to your VPS, and issue the command pm2 l, the previously running process should display and display status as running.

3. Repository

https://gitlab.com/blurt/openblurt/blurtopian/blurtopian-autoclaim-bot


Find my contributions valuable? Please consider voting for my witness:

https://blurtwallet.com/~witnesses?highlight=eastmael

Banner3_Orange.png

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE BLURT!
Sort Order:  

Good work!

Thank you. Never could have done it without your help.

Nice and detailed explanation
keep up
I'll figure it out!

Thanks. Glad you liked it.

Good that you now offer a solution for claiming rewards. Since claiming transaction isn't free, can a minimum claim amount also be set in addition to setting a time interval? #JustAsking. I don't actually need it as I don't earn too much rewards so I don't miss much if I can't claim it for even a week. LO!

This is noted. Thanks for the suggestion.

Congratulations, your post has been curated by @r2cornell-curate.

Manually curated by @melissaofficial

Also, find us on Discord (https://discord.gg/BAn2amn)
logo3 Discord.png

That's good work. Love to stay with you