Steem.Js for dummies #7: Sending Steem/SBD to another usersteemCreated with Sketch.

in #utopian-io7 years ago

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



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Thats an awesome tutorial my friend, you are google star now ;)

Really? You found me on Google? haha

yeah ;)

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

Thanks for your work!

Thank you!

me parecio agradable aunque aun no me he sentado a usar lenguaje HTML

That's Javascript =p

Congratulations! Your post has been manually selected by @flauwy for the daily @utopian-1up curation trail. 11 Steemians/Utopians are following my trail and have upvoted your post for $1.44 in total. Join the discussion for how to make Utopian 1UP a community effort to select the best Utopian contributions of the day. You can follow the @utopian-1up trail on SteemAuto (tutorial).

Disclaimer: 1UP is in not affiliated or organized by the official Utopian.io project!

Hey @stoodkev I am @utopian-io. I have just upvoted you at 7% Power!

Achievements

  • WOW WOW WOW People loved what you did here. GREAT JOB!
  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • You are generating more rewards than average for this category. Super!;)
  • Seems like you contribute quite often. AMAZING!

Suggestions

  • Work on your followers to increase the votes/rewards. I follow what humans do and my vote is mainly based on that. Good luck!
  • Contribute more often to get higher and higher rewards. I wish to see you often!
  • I introduced a competition factor. My vote is based also on how competitive the category used is.

Human Curation

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

H @stoodkev!
I've got important question and cannot find the answer.

I am trying to create bot which does something after it receives steem, but I cannot find the way to create callback something like "OnMoneyReceived".

I was trying to do it with found in library:
setPendingTransactionCallback
but it throws error and does nothing maybe you can help me?

I will send you a little tip for this and of course I will follow and upvote you.

Hi, I ll look into it, never done that so far though.

Please, I will really appropriate it. :)

Hey check my today's post. I did it for you;)

Hey, hey I've already did it and I send you a tip for your help :)
I am building something crazy right now :)

Dear @stoodkev can give an idea , How i post an image using steemjs

thanks for the knowledge