Nodejs Tool To Do Airdrops On Steem-Engine For Free

in #utopian-io5 years ago

Project introduction

Repository: https://github.com/Rishi556/EngineAirdrop
What is it: An easy way to send airdrops to users on Steem-Engine for free with a little bit of knowledge of how to use Nodejs.

Development

Development went by pretty well for the most part, except for a few things that I struggled with. This was only my second time making CLI tools with Nodejs and I couldn't figure a few things out.

The first problem I stumbled onto was that I couldn't get the CLI commands to work without being in the directory with the project. After googling some, I realized that I needed to have the WHOLE filepath for the files that I wanted to be read. As seen in this commit I changed it so that rather than just using the file's name, it has the whole file path.

var path = require('path').dirname(require.main.filename)
fs.readFile("./ToSend.txt", (err, data) => {
fs.readFile(`${path}/ToSend.txt`, (err, data) => {
//more code in here
})

It worked perfectly after changing it to that.

Another problem that I ran into was with Steem-Engine. I wanted to make sure that the account had enough tokens to send if it was transferring rather than issuing the token. I was trying to use the findOne method in ssc incorrectly. Glancing through the docs, I saw id and was trying to use that rather than account for the username. That just kept resulting in errors. After looking at the docs some more, I realized that I needed to use account, and that worked perfectly. Commit here.

By far the hardest problem I had was with the 3 second limit with STEEM. I could only broadcast a coustom_json once per block, and so needed to set a delay. So I decided to use setInterval which lets something occur every x. But I realized that I didn't know how to stop that. I googled about it and discovered I could use clearInterval to stop the interval from occurring anymore. With that I tried a few different ways, all involving a count variable that checks if it was greater than the length of all the people to send to and would clear the interval if it was. I started with an if statement inside the callback after sending the transaction to Steem, but that kept going no matter what. Other methods didn't work, until I decided to have an if-else statement before broadcasting that checked if the count variable was greater than the length and would only broadcast if it wasn't. That worked without flaws. Commit here.


Usage

I tried to make usage as simple as possible. Everything is detailed in the readme, and so I've just copy pasted that onto here.

EngineAirdrop is a free tool for anyone to use to send airdrops to recipients on Steem-Engine.

To use this, simply clone this, cd to the directory and use npm i to install the dependencies.
Next use npm link to be able to use the command line interface for it.

Now edit the ToSend.txt file. Follow this format, each person should be on their own line, followed by a comma and how much they should receive,

username,amountToSend
username2,amountToSend2

There's an example of this within the file itself, or here : https://github.com/Rishi556/EngineAirdrop/blob/master/ToSend.txt.

Next edit the config.js file. There's four fields and you need to change each one to be correct for you. Theres instructions right next to each field if you have any questions.

Finally, you are ready to start.

You can see who'll get how much by typing in airdrop genList. Use this to confirm that each person is getting the correct amount and make the changes if necessary.

You can also use airdrop processList to make sure that all accounts are on steem. If an array with names is returned, those are the ones that don't have steem accounts.

airdrop help gives you the help menu.

When you are ready to send, you can use airdrop send to start the sending process. It takes some time and an estimate will be printed out for you. If there are any errors, they'll be printed out in human readable form.

Here's an example of it running with the config filled out for TROLL transfers with the sending to the users in the example ToSend file.

Screen Shot 2019-05-12 at 5.37.06 PM.png


Final Thoughts

I think that this will be quite useful for those who want to do airdrops with Steem-Engine. Halfway through writing this, I realized that Steem-Engine had a tool themselves for this, but theirs cost 20 ENG while this is free for those who understand how to use it. I was debating on wether or not to stop work on this, but decided I've come too far to stop now. Thats why there's a moderately large timegap between these two commits.

Screen Shot 2019-05-12 at 5.39.47 PM.png

I also with that my code was a little bit cleaner. While I use functions to keep the chunks small, those can get quite messy. Avoiding pyramids of doom is also something I've been trying to get better at, and while its a lot better from some of my older code, I still think I can get better. Using return is a nice way to exit the function which is better than the if-else that I used to use.

Github Profile: https://github.com/Rishi556

Sort:  
  • Good article with images and code samples, could use an intro image.
  • Try making you commit comments more detailed.
  • List your pull request links or commit list for your next update.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Chat with us on Discord.

[utopian-moderator]

Thanks for the suggestions, will do the next time I make a utopian post.

Thank you for your review, @helo! Keep up the good work!

This comment was intentionally left blank. ;-)

We keep learning as we write. Interesting projects you undertake.

Posted using Partiko Android

Thanks, was considering quitting halfway through as there was something already out to do this, but it'd cost people some money, and this can be used for free with a little bit of skill so I decided to continue. Show us more of your code.

How did I know you were going to ask about my code. Hopefully will get a basic code posted tomorrow.

Posted using Partiko Android

Woot woot! looking good!

You got voted by @curationkiwi thanks to Princess! This bot is managed by KiwiJuce3 and run by Rishi556, you can check both of them out there. To receive upvotes on your own posts, you need to join the Kiwi Co. Discord and go to the room named #CurationKiwi. Submit your post there using the command "!upvote (post link)" to receive upvotes on your post. CurationKiwi is currently supported by donations from users like you, so feel free to leave an upvote on our posts or comments to support us!

This post has received a 1.56 % upvote from @drotto thanks to: @curationkiwi.

Hi, @rishi556!

You just got a 3.2% upvote from SteemPlus!
To get higher upvotes, earn more SteemPlus Points (SPP). On your Steemit wallet, check your SPP balance and click on "How to earn SPP?" to find out all the ways to earn.
If you're not using SteemPlus yet, please check our last posts in here to see the many ways in which SteemPlus can improve your Steem experience on Steemit and Busy.

Congratulations @rishi556! You have completed the following achievement on the Steem blockchain and have been rewarded with new badge(s) :

You published a post every day of the week

You can view your badges on your Steem Board and compare to others on the Steem Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

To support your work, I also upvoted your post!

Do not miss the last post from @steemitboard:

New japanese speaking community Steem Meetup badge
Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Hi @rishi556!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hey, @rishi556!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support Utopian.io!
Simply set @utopian.pay as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.26
TRX 0.11
JST 0.032
BTC 63510.75
ETH 3065.54
USDT 1.00
SBD 3.82