Steem Engine - Basics

in utopian-io •  3 years ago  (Edited)

image.png


Repository:

https://github.com/harpagon210/sscjs

What Will I Learn?

  • You will learn how to interact with SSC
  • You will learn how to get a user information

Requirements

  • Node.JS
  • SSCJS (Steem Engine JS)

Difficulty

  • Basic

Curriculum

The Tutorial

Hello guys, today we will learn the basics of SSC.

Creating The Project

first, create a new project

npm init

I'm using the main script as app.js.
now just press enter until it's done,
now you can install the packages and the SSC package

npm i sscjs --save

image.png

because I already updated the packages I don't have any to install.

Great!

Importing SSC to NodeJS

first, create your script app.js or whatever name you chose.
image.png

Good, now we need to import ssc and use it with the API.

let SSC = require('sscjs');

const ssc = new SSC('https://api.steem-engine.com/rpc');

cool, now to test that it's working fine

ssc.stream((err, res) => {
    console.log(err, res);
});

image.png
so we're getting a lot of blockchain data, currently, we'll not use it but as you can see it's working perfectly!

Getting User Information

so the sscjs is working just like a database, you need to search it by queries, so we will search my account,
we're searching for the tokens, the balances with the account name of @lonelywolf (me)

ssc.find(
  'tokens', 
  'balances', 
  {account:"lonelywolf" },
  1000,
  0,
  [],
   (err, result) => {
    console.log(result);
   }
);

great, now run the script and we will see that we will get a JSON objects for every token!

image.png

so, for example, we can use it to get the voting power on WEED platform such as @blockchainstudio do at https://economicstudio.github.io/vp/?a=lonelywolf&t=WEED

so for this, we need to get just WEED, how we do it?
we're doing the same just after account we're taking the symbol name which is the token name (WEED)

ssc.find(
  'tokens', 
  'balances', 
  {account:"lonelywolf", symbol: "WEED" },
  1000,
  0,
  [],
   (err, result) => {
    console.log(result);
   }
);

now all we will get is the WEED object!

image.png

we can do the same for PAL, etc.
image.png

Great, here we're done with the basic tutorial, stay tuned for the next tutorial, I'm sure you will learn new things ;)

Proof of Work Done

https://github.com/upmeboost-utopian

Have a great day!

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 STEEM!
Sort Order:  

Thank you for your contribution @lonelywolf.
After reviewing your tutorial we suggest the following points listed below:

  • Your tutorial is quite short for a good tutorial. We recommend you aim for capturing at least 2-3 concepts.

  • Again: Using the first person in the tutorials makes it difficult to understand the tutorials. We suggest using the third person in your text.

  • Your tutorial is very interesting but it is necessary to detail more.

Thank you for your work in developing this tutorial.
Looking forward to your upcoming tutorials.

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]

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

Hi, @lonelywolf!

You just got a 0.18% 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.

Hi @lonelywolf!

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, @lonelywolf!

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!

Hello lonelywolf, welcome to Partiko, an amazing community for crypto lovers! Here, you will find cool people to connect with, and interesting articles to read!

You can also earn Partiko Points by engaging with people and bringing new people in. And you can convert them into crypto! How cool is that!

Hopefully you will have a lot of fun using Partiko! And never hesitate to reach out to me when you have questions!

Cheers,
crypto.talk
Creator of Partiko