The purpose of this tutorial is How to get account replies and a) demonstrate how to use get_state api function call, and b) fetch recent replies for the content of specific account, in this case @steemitblog.

We focus on listing part of the content with simply UI as well as explain the most commonly used fields from the response object as well as parse body of each comment.

Intro

We are using get_state function with dsteem, which is straight-forward and this function returns current state of the network as well as additional content given proper query. Each content body, as we described in previous tutorials, is written markdown and submitted to the blockchain by many applications built on top of Steem. For that reason we are using remarkable npm package to parse markdown in a readable format.

Steps

1. App setup

As usual, we have public/app.js file which holds the javascript part of the tutorial. In first few lines we define, configure library and packages.

constdsteem=require('dsteem');letopts={};//connect to production serveropts.addressPrefix='STM';opts.chainId='0000000000000000000000000000000000000000000000000000000000000000';//connect to server which is connected to the network/productionconstclient=newdsteem.Client('https://api.steemit.com');constRemarkable=require('remarkable');constmd=newRemarkable({html:true,linkify:true});

dsteem is pointing to the main network and proper chain_id, addressPrefix and connection server.
remarkable is assigned to md variable with linkify and html options, allowing markdown parsing links and html properly.

2. Query result

Next, we have main function which fires when page is loaded.

// query string, fetching recent replies for @steemitblog accountconstquery='/@steemitblog/recent-replies';client.database.call('get_state',[query]).then(result=>{// work with state object});

Query is the path which we want to extract from Steem blockchain state. In our example we are using @steemitblog account and recent-replies to its content. Result will be current state object with various information as well as content object property holding content of the query.

We check if content is not an empty object and we iterate through each object via its key and extract, author, format created date and time, parse body markdown, get net_votes on that reply. Pushing each list item separately and displaying it. That’s it!