Steem Engine - Basics

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@lonelywolf·
0.000 HBD
Steem Engine - Basics
![image.png](https://steemitimages.com/p/3LxrHFUF5NKfPD93YzFPH3SwWPqB6V57DMv9kPymkmo5DL88SVKKnGmuhSnnDQCqc9tWtncrQjD3kC7RgSPCB2Th7JDUmPEJQvDZjgaxmaJrXSApAkVL8pNv4SfJQR2UT5PCg5riwqwWNFX4jamRekW9wsq7MN23NwzPVurSm92x8x7UwxFZ6Bn5iqa1koovRMUrZk3XQHYYTQ1KTR86RFaDvjUqCxpTUu7mhN)

---
#### 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
- [SteemJS #1](https://steemit.com/utopian-io/@lonelywolf/steem-js-tutorials-1-basics-validating-wif-key)
- [NodeJS #1](https://steemit.com/utopian-io/@lonelywolf/nodejs-tutorials-1-creating-a-static-site-node-js)

### 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](https://files.steempeak.com/file/steempeak/lonelywolf/iUSsQ9AR-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](https://files.steempeak.com/file/steempeak/lonelywolf/nf6Z4q8L-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](https://files.steempeak.com/file/steempeak/lonelywolf/px0TL5nw-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](https://files.steempeak.com/file/steempeak/lonelywolf/hqsypVAn-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](https://files.steempeak.com/file/steempeak/lonelywolf/G5AQHoLL-image.png)

we can do the same for PAL, etc.
![image.png](https://files.steempeak.com/file/steempeak/lonelywolf/e7HNtXt2-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!
👍 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,