Steem.Js for dummies #7: Sending Steem/SBD to another user

Words
193
Reading
1 min
Listen
Play
9y

image.png

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:

image.png

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.

  • from is the account that will send the transfer

  • As you can guess, to is 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);
});

image.png

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 :

image.png

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);
});

image.png

Awesome, it wordked, let's check my Wallet to make sure:

image.png

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!

stoodkev@stoodkev



Posted on Utopian.io - Rewarding Open Source Contributors

Steem.Js for dummies #7: Sending Steem/SBD to another user | Ecency