Today we will learn how to use Steemjs to send a reward in either Steem or SBD to any other account.
For this, as usual, let's take a look at the documentation, that can be found on the SteemJs Github repository.
So let's take a look at the transfer function:
Here, we need five things:
Wif, it is the private active WIF. To find it, first go to your wallet, and then to the Permissions tab, in there you will find the public active key, click on the nearby button to show the private active key that you need to realize a transfer programatically.fromis the account that will send the transferAs you can guess,
tois the account that will receive this transfer.amount, that's where it gets tricky, there is no information on what this transfer is about. I've never used it either, so let's try it out!
-memo can be kept empty. it represents the message that will accompany your transfer.
steem.broadcast.transfer(XXXXXXX', 'steem-plus', 'stoodkev', 12, 'Hi', function(err, result) {
console.log(err, result);
});
Wow wow wow! Okay, there is something wrong here! Let's take a look: the function couldn't trim, it should mean that we need to put a String in there. I'm guessing we need to specify steem or SBD with it:
steem.broadcast.transfer(XXXXXXX', 'steem-plus', 'stoodkev', '1 SBD', 'Hi', function(err, result) {
console.log(err, result);
});
Okay, still not :
After digging for a while, I finally found out that we need three decimals for the amount to be accepted:
steem.broadcast.transfer(XXXXXXX', 'steem-plus', 'stoodkev', '1.000 SBD', 'Hi', function(err, result) {
console.log(err, result);
});
Awesome, it wordked, let's check my Wallet to make sure:
That all worked, finally!
I chose to show all my trial and error process here to show you that if you stay motivated and keep digging, you can find what you need and succeed in what you want to do.
Hope this helps!
Posted on Utopian.io - Rewarding Open Source Contributors