https://github.com/steemit/steem-js
Choose one of the following options:
This tutorial will discuss about every function used in Formatter section inside Steem API docs https://github.com/steemit/steem-js/tree/master/doc#formatter. The tutorial will cover these functions in details
//code to create passowrd.
var password = steem.formatter.createSuggestedPassword();
console.log(password);
The first function is using steem.formatter.createSuggestedPassword() method to create appropriate password for your steemit account and storing inside password variable. console.log(password) is printing password over console window.
posting,active,memo keys depends on your account password, Just to inform you in case.//code to create comment permlink.
var parentAuthor = 'ned';
var parentPermlink = 'a-selfie';
var commentPermlink = steem.formatter.commentPermlink(parentAuthor, parentPermlink);
console.log(commentPermlink);
ned here is a steemit user (@ned) and
a-selfie is a permlink of his post https://steemit.com/steemit/@ned/a-selfie that gets store inside variables. Now using steem.formatter.commentPermlink() method, we can easily get a reply permlink over the post with which we can then post comment
https://steemit.com/magnolia/@tuck-fheman/re-ned-magnolia-20180822t152934021z@tuck-fheman and post permlink is magnolia#@tuck-fheman and comment got to this post permlink is re-ned-magnolia-20180822t152934021z.
In above image example of second function, i used my post https://steemit.com/blog/@genievot/introducing-steemit-tasks-landing-page-for-listing-all-tasks-in-one-place. In console we got a unique permlink to post a comment on this post. You can see reprefix on permlink to express reply.
So, Above we covered the URL concept of replying on a steem post as well.
//code to get account value.
var steemPower = steem.formatter.estimateAccountValue(account);
The proper way to implement this is
steem.api.getAccounts(["genievot"], function(e1, accounts){
var accountValueInUSD = steem.formatter.estimateAccountValue(accounts[0])
.catch(function (err) { console.log(err); })
.then(function (data) { console.log(data); });
});
The above function is using callback function to get estimate account value. First using steem.api.getAccounts([username],function(e, r){} we get the account details of any username. Then inside it we uses steem.formatter.estimateAccountValue(accounts[0]) to get estimated values of all the assets of account[0] (Which is first account in getAccounts method.
It will return dollar value of the assets of account in console.log or if error occur then catch the error and print it.
First example with just getAccounts function.
Now with proper method.
//code to obtain reputation.
var reputation = steem.formatter.reputation(3512485230915);
console.log(reputation);
This function using steem.formatter.reputation(reputation) to get your current reputation based on the number returned by getAccounts method.
using reputation method.
//code to convert vest to your current steem power.
var steemPower = steem.formatter.vestToSteem(vestingShares, totalVestingShares, totalVestingFundSteem);
console.log(steemPower);
The function steem.formatter.vestToSteem()will convert Vests to SteemPower, this method is accepting 3 parameters. vestingShares,totalVestingShares,totalVestingFundSteem. To give input in the arguments, You should run getAccounts function and this function:
steem.api.getDynamicGlobalProperties(function(err, result) {
console.log(err, result);
});
getAccounts function will get vestingShares and for other two parameters totalVestingShares, ,totalVestingFundSteem , we need 2nd function getDynamicGlobalProperties
Now put all the values inside parameter and run the method.