dsteem vs steemjs

I tested out dsteem library recently, and I really like about it. Therefore, I am writing a post to make a brief comparison with steemjs (which I had been using it in the previous project)

Screen Shot 2018-04-21 at 11.59.28 AM.png

Since, dsteem is written in TypeScript, type is much more easier to be check with VSCode

dsteem

GitHub repo

  • Written in TypeScript
  • Well documented

steemjs

GitHub repo

  • Written in JS
  • Official repo by steemit
  • More stars on GitHub

Let's make a simple use case

Get all the latest post on the blockchain

in dsteem, (using TypeScript)

import {Client, BlockchainMode} from 'dsteem'
const client = new Client('https://api.steemit.com')
const stream = client.blockchain.getOperationsStream({ mode: BlockchainMode.Latest })
stream.on('data', operation => {
  if (operation.op[0] == 'comment') {
    // insert code here
  }
}

in steemjs, (using JavaScript)

const steem = require('steem')
steem.api.streamTransactions('head', function(err, result) {
  if (result.operations[0][0] === 'comment') {
    // insert code here
  }
})

Comment

in dsteem,

let key = PrivateKey.fromLogin(ACCOUNT_NAME, ACCOUNT_KEY, 'posting')
client.broadcast.comment({
  parent_author: data.author,
  parent_permlink: data.permlink,
  author: process.env.ACCOUNT_NAME,
  permlink: "random",
  title: "",
  body: "the comment body",
  json_metadata: "{ tags: ['cn-malaysia'], app: 'cn-malaysia' }"
}, key)

in steemjs,

steem.broadcast.comment(
    process.env.ACCOUNT_KEY,
    data.author,
    data.permlink,
    process.env.ACCOUNT_NAME,
    'insert_some_title',
    '',
    commentContent,
    { tags: ['cn-malaysia'], app: 'cn-malaysia' },
    function(err, result) {
      console.log(err, result);
    }
  );

Final thoughts

I am still trying out on dsteem, but my feel on dsteem are much easier to be used since it has TypeScript intergrated with it. The only issue I had with SteemJS is for async/await code and not well documented official documentation.

One drawback about dsteem is that is does not have much example, so I had to trial and error to test a certain code.

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
3 Comments