new EasySteem(appId, appName, appVersion)
initialize easysteem
Parameters:
Name | Type | Description |
---|---|---|
appId |
String | app identifier on your steemconnect dashboard (https://steemconnect.com/dashboard) |
appName |
String | app name that will be part of the metadata posted within your app |
appVersion |
String | app version that will be part of the metadata posted within your app |
Members
-
static ORDER_OPTIONS
-
order options: REPUTATION, PAYOUT, PERCENT, OLDEST, NEWEST
-
static REWARD_OPTIONS
-
reward options available on Steem: CENT_PERCENT_SP, FIFTY_PERCENT_SP_SBD or NONE
Methods
-
bytesToSize(bytes, numberDecimals) → {String}
-
convert a number of bytes into a readable size (1B, 1KB, 1MB, ...)
Parameters:
Name Type Description bytes
Number the bytes to convert
numberDecimals
Number default 2, number of decimals to return
Returns:
String -formated string representing the size
-
calculateBandwidth(user, numberDecimals, refreshSteemProperties) → {JSON}
-
calculate the bandwidth information of a user
Parameters:
Name Type Default Description user
JSON a user object
numberDecimals
Number 2 number of decimals to return, default 2
refreshSteemProperties
Boolean true default true, refresh the Steem properties (Steem rate, etc...)
Returns:
JSON -json with the bandwidth information (used, allocated in percents and bytes)
Example
easysteem.me() .then(user => { easysteem.calculateBandwidth(user.account, 3) .then(result => console.log(result)) }) .catch(error => console.error(error.error, error.error_description)) /*{ bytes: { allocated: "8.106 MB", remaining: "8.088 MB", used: "18.421 KB" }, percents: { remaining: "99.778", used: "0.222" } }*\/
-
calculateEstimatedAccountValue(user, numberDecimals, refreshSteemProperties)
-
calculate an estimation of an account value
Parameters:
Name Type Default Description user
JSON a user object
numberDecimals
Number 2 default 2, number of decimals to return
refreshSteemProperties
Boolean true default true, refresh the Steem properties (Steem rate, etc...)
-
calculatePayout(post) → {JSON}
-
Calculates Payout Details
Parameters:
Name Type Description post
JSON post JSON
Returns:
JSON -JSON representing the payout details
-
calculateReputation(user, numberDecimals) → {Number}
-
calculate the reputation in a more readable way
Parameters:
Name Type Description user
JSON a user object
numberDecimals
* number of decimals to return, default 2
Returns:
Number -return the calculated reputation
-
calculateTotalDelegatedSP(user, totalVestingShares, totalVestingFundSteem)
-
calculate the total amount of Steem Power delegated
Parameters:
Name Type Description user
JSON totalVestingShares
Number totalVestingFundSteem
Number -
calculateUserVestingShares(user) → {Number}
-
calculate a user's vesting shares
Parameters:
Name Type Description user
JSON a user object
Returns:
Number -the user's vesting shares
-
calculateVoteValue(user, voteWeight, numberDecimals, refreshSteemProperties) → {Number}
-
calculate the Steem value of a user vote
Parameters:
Name Type Default Description user
JSON a user object
voteWeight
Number 100 the weight of the vote to calculate
numberDecimals
Number 2 default 2, number of decimals to return
refreshSteemProperties
Boolean true default true, refresh the Steem properties (Steem rate, etc...)
Returns:
Number -the value of the vote in Steem
-
calculateVotingPower(user, numberDecimals) → {Number}
-
calculate the voting power of a user
Parameters:
Name Type Default Description user
JSON a user object
numberDecimals
Number 2 number of decimals to return, default 2
Returns:
Number -a number representing the voting power of the user
-
checkPermLinkLength(permlink)
-
check and modifiy a permlink if necessary to fit the Steem blockchain requirements
Parameters:
Name Type Description permlink
String permlink to check
Returns:
-permlink checked and potentially modified
-
createComment(parentAuthor, parentPermlink, body) → {Promise.<JSON>}
-
comment a post or a comment
Parameters:
Name Type Description parentAuthor
String author of the post or comment to comment
parentPermlink
String permlink of the post or comment to comment
body
String markdown formatted body
Returns:
Promise.<JSON> -return the transaction details
Example
easysteem.createComment('harpagon', 'test-title', '**test comment**') .then(result => console.log(result)) .catch(error => console.error(error.error, error.error_description))
-
createPermlink(title, parentAuthor, parentPermlink) → {String}
-
create a permlink
Parameters:
Name Type Default Description title
String title of the post (empty for a comment)
parentAuthor
String null parent author of the comment
parentPermlink
String null parent permlink of the comment
Returns:
String -permlink
-
createPost(title, body, category, tags, rewardOption, beneficiaries, jsonMetadata) → {Promise.<JSON>}
-
post a new article
Parameters:
Name Type Description title
String title of the post
body
String markdown formatted body
category
String category of the post
tags
Array.<String> tags of the post
rewardOption
String default is REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD (REWARD_OPTIONS.CENT_PERCENT_SP, REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD or REWARD_OPTIONS.NONE
beneficiaries
Array.<JSON> array containing the beneficiaries and the weight for their reward ex: [{ 'account': 'harpagon', 'weight': 100 }]
jsonMetadata
JSON metadata attached to this post
Returns:
Promise.<JSON> -return the transaction details
Example
easysteem.createPost( 'title', 'body', 'category', ['tag1', 'tag2'], EasySteem.REWARD_OPTIONS.CENT_PERCENT_SP, // default is set to REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD [ { 'account': 'harpagon', 'weight': 50.99 // represents the percentage (50.99% in this case) }, { 'account': 'account', 'weight': 0.01 // represents the percentage (0.01% in this case) } ], { 'format': 'html' // default is set to mardown but you can override }) .then(result => console.log(result)) .catch(error => console.error(error.error, error.error_description))
-
deletePostOrComment(permlink) → {Promise.<JSON>}
-
delete a post or a comment
Parameters:
Name Type Description permlink
String permlink of the post or comment to delete
Returns:
Promise.<JSON> -return the transaction details
-
downvote(postAuthor, postPermlink, weigth) → {Promise.<JSON>}
-
downvote a post
Parameters:
Name Type Description postAuthor
String the username of the author of the post
postPermlink
String the permlink of the post
weigth
Number the weight of the vote (ex: 0, 1.24, 49.9, 100)
Returns:
Promise.<JSON> -return the transaction details
Example
easysteem.downvote('harpagon', 'test-permlink', 49.99) .then(result => console.log(result)) .catch(error => console.error(error.error, error.error_description))
-
follow(author) → {Promise.<JSON>}
-
follow an author
Parameters:
Name Type Description author
String author to follow
Returns:
Promise.<JSON> -return the transaction details
-
getActiveVotes(author, permlink, orderBy) → {Array.<JSON>}
-
get the active votes of a post or comment
Parameters:
Name Type Description author
String author of the post or comment
permlink
String permlink of the post or comment
orderBy
String default EasySteem.ORDER_OPTIONS.PAYOUT but REPUTATION, PERCENT, PAYOUT available
Returns:
Array.<JSON> -return the active votes of the post or comment ordered
-
getContent(account, permlink) → {Promise.<JSON>}
-
get the content of a post or comment
Parameters:
Name Type Description account
String the account that owns the post or comment
permlink
String the permlink of the post or comment
Returns:
Promise.<JSON> -return the content of the post or comment
-
getContentReplies(author, permlink, orderBy) → {Array.<JSON>}
-
get the replies to a post or comment
Parameters:
Name Type Description author
String author of the post or comment
permlink
String permlink of the post or comment
orderBy
String default EasySteem.ORDER_OPTIONS.PAYOUT but OLDEST, NEWEST, REPUTATION, PAYOUT available
Returns:
Array.<JSON> -return the comments of the post or comment ordered
-
getCryptoCurrencyPrice(currency) → {Number}
-
get the USD price of a crypto currency
Parameters:
Name Type Description currency
String a cryptocompare compatible crypto currency code
Returns:
Number -the USD price of the crypto currency
-
getFollowers(username) → {Array.<JSON>}
-
get the followers of a user
Parameters:
Name Type Description username
String the username for which you want to retrieve the followers
Returns:
Array.<JSON> -an array containing the followers
-
getFollowing(username) → {Array.<JSON>}
-
get the following of a user
Parameters:
Name Type Description username
String the username for which you want to retrieve the following
Returns:
Array.<JSON> -an array containing the following
-
getLoginUrl(scope, callbackUrl, state) → {String}
-
get the url where the user can log into steemconnect
Parameters:
Name Type Default Description scope
Array.<String> scope of your application (https://github.com/steemit/steemconnect/wiki/OAuth-2#scopes)
callbackUrl
String url where the users will be redirected after interacting with steemconnect
state
String null data that will be passed to the callbackURL after the user has logged in
Returns:
String -url to log the user in
-
getUserAccount(username) → {JSON}
-
retrieve a user account
Parameters:
Name Type Description username
String username for which you want to retrieve the account details
Returns:
JSON -user account details
-
getUserAccounts(usernames) → {JSON}
-
retrieve a user account
Parameters:
Name Type Description usernames
Array.<String> usernames for which you want to retrieve the account details
Returns:
JSON -user account details
-
ignore(author) → {Promise.<JSON>}
-
ignore an author
Parameters:
Name Type Description author
String author to ignore
Returns:
Promise.<JSON> -return the transaction details
-
logout() → {Promise.<JSON>}
-
log the current user out
Returns:
Promise.<JSON> -return the transaction details
-
me() → {Promise.<JSON>}
-
get the profile of the current user
Returns:
Promise.<JSON> -return the user profile
-
orderComments(votes, orderBy)
-
orders the comments
Parameters:
Name Type Description votes
Array.<JSON> array containing the comments
orderBy
String default EasySteem.ORDER_OPTIONS.PAYOUT but OLDEST, NEWEST, REPUTATION, PAYOUT available
-
orderVotes(votes, orderBy)
-
orders the votes
Parameters:
Name Type Description votes
Array.<JSON> array containing the votes
orderBy
String default EasySteem.ORDER_OPTIONS.PAYOUT but REPUTATION, PERCENT, PAYOUT available
-
parsePayoutAmount(amount) → {String}
-
parse a payout amount from AMOUNT SDB to $AMOUNT
Parameters:
Name Type Description amount
String string representing the SBD amount
Returns:
String -parsed payout amount
-
parseReturnedUrl(url) → {JSON}
-
parse a url returned by Steemconnect to get the account, the access token and the expiration time
Parameters:
Name Type Description url
String url to parse
Returns:
JSON -account, accessToken and expTime
Example
easysteem.parseReturnedUrl('https://my-awesome-website.com/steemconnect/?access_token=THISISASECUREDTOKEN&expires_in=604800&username=harpagon)
-
postOperation(parentAuthor, parentPermlink, title, body, tags, rewardOption, beneficiaries, jsonMetadata) → {Promise.<JSON>}
-
post on the Steem blockchain
Parameters:
Name Type Default Description parentAuthor
String parent author of the post or comment
parentPermlink
String parent permlink of the post or comment
title
String title of the post (empty for a comment)
body
String markdown formatted body
tags
Array.<String> tags of the post
rewardOption
String null REWARD_OPTIONS.CENT_PERCENT_SP, REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD or REWARD_OPTIONS.NONE
beneficiaries
Array.<JSON> array containing the beneficiaries and the weight for their reward
jsonMetadata
JSON metadata attached to this post
Returns:
Promise.<JSON> -return the transaction details
-
reblog(author, permlink) → {Promise.<JSON>}
-
reblog a post
Parameters:
Name Type Description author
String the author of the post to reblog
permlink
String the permlink of the post to reblog
Returns:
Promise.<JSON> -return the transaction details
-
refreshSteemProperties()
-
Refresh the global propertis linked to Steem and the rates
-
setAccessToken(accessToken)
-
set the steemconnect oAuth2 access token
Parameters:
Name Type Description accessToken
String steemconnect oAuth2 access token
-
setAccount(account)
-
set the steem account that will be used to perform the actions
Parameters:
Name Type Description account
String steem account
-
sharesToSteem(rshares)
-
converts a number of shares into a number of Steem
Parameters:
Name Type Description rshares
Number number of shares
Returns:
-the shares converted into a Steem value
-
unfollow(author) → {Promise.<JSON>}
-
unfollow an author
Parameters:
Name Type Description author
String author to unfollow
Returns:
Promise.<JSON> -return the transaction details
-
updateComment(permlink, body, parentAuthor, parentPermlink) → {Promise.<JSON>}
-
update a comment
Parameters:
Name Type Default Description permlink
String permlink of the post or comment to comment
body
String markdiwn formatted body
parentAuthor
String null parent author of the post or comment to comment (if not provided, this will be retrieved via the Steem API)
parentPermlink
String null parent permlink of the post or comment to comment (if not provided, this will be retrieved via the Steem API)
Returns:
Promise.<JSON> -return the transaction details
Example
easysteem.updateComment('re-harpagon-test-title-20180312t034345437z', '**test update comment 3**') .then(result => console.log(result)) .catch(error => console.error(error.error, error.error_description))
-
updatePost(permlink, title, body, tags, jsonMetadata, category) → {Promise.<JSON>}
-
update an existing article
Parameters:
Name Type Default Description permlink
String permlink of the post to update
title
String title of the post
body
String markdown formatted body
tags
Array.<String> tags of the post
jsonMetadata
JSON metadata attached to this post
category
String null will be used to update the post, if not provided, it will be retrieved via the Steem API (however the category can't be updated)
Returns:
Promise.<JSON> -return the transaction details
Example
easysteem.updatePost( 'permlink', 'title', 'body', ['tag1', 'tag2'], { 'format': 'html' // default is set to mardown but you can override }, 'category') .then(result => console.log(result)) .catch(error => console.error(error.error, error.error_description))
-
updateUserMetadata(metadata) → {Promise.<JSON>}
-
update the current user metadata
Parameters:
Name Type Description metadata
JSON Returns:
Promise.<JSON> -return the transaction details
-
upvote(postAuthor, postPermlink, weigth) → {Promise.<JSON>}
-
upvote a post
Parameters:
Name Type Description postAuthor
String the username of the author of the post
postPermlink
String the permlink of the post
weigth
Number the weight of the vote (ex: 0, 1.24, 49.9, 100)
Returns:
Promise.<JSON> -return the transaction details
Example
easysteem.upvote('harpagon', 'test-permlink', 49.99) .then(result => console.log(result)) .catch(error => console.error(error.error, error.error_description))
-
vestToSteem(vestingShares, totalVestingShares, totalVestingFundSteem)
-
convert an amount of vestings into an amount of Steem
Parameters:
Name Type Description vestingShares
Number totalVestingShares
Number totalVestingFundSteem
Number