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 bytesNumber the bytes to convert
numberDecimalsNumber 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 userJSON a user object
numberDecimalsNumber 2 number of decimals to return, default 2
refreshSteemPropertiesBoolean 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 userJSON a user object
numberDecimalsNumber 2 default 2, number of decimals to return
refreshSteemPropertiesBoolean true default true, refresh the Steem properties (Steem rate, etc...)
-
calculatePayout(post) → {JSON}
-
Calculates Payout Details
Parameters:
Name Type Description postJSON 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 userJSON 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 userJSON totalVestingSharesNumber totalVestingFundSteemNumber -
calculateUserVestingShares(user) → {Number}
-
calculate a user's vesting shares
Parameters:
Name Type Description userJSON 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 userJSON a user object
voteWeightNumber 100 the weight of the vote to calculate
numberDecimalsNumber 2 default 2, number of decimals to return
refreshSteemPropertiesBoolean 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 userJSON a user object
numberDecimalsNumber 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 permlinkString 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 parentAuthorString author of the post or comment to comment
parentPermlinkString permlink of the post or comment to comment
bodyString 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 titleString title of the post (empty for a comment)
parentAuthorString null parent author of the comment
parentPermlinkString 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 titleString title of the post
bodyString markdown formatted body
categoryString category of the post
tagsArray.<String> tags of the post
rewardOptionString default is REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD (REWARD_OPTIONS.CENT_PERCENT_SP, REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD or REWARD_OPTIONS.NONE
beneficiariesArray.<JSON> array containing the beneficiaries and the weight for their reward ex: [{ 'account': 'harpagon', 'weight': 100 }]
jsonMetadataJSON 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 permlinkString 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 postAuthorString the username of the author of the post
postPermlinkString the permlink of the post
weigthNumber 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 authorString 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 authorString author of the post or comment
permlinkString permlink of the post or comment
orderByString 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 accountString the account that owns the post or comment
permlinkString 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 authorString author of the post or comment
permlinkString permlink of the post or comment
orderByString 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 currencyString 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 usernameString 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 usernameString 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 scopeArray.<String> scope of your application (https://github.com/steemit/steemconnect/wiki/OAuth-2#scopes)
callbackUrlString url where the users will be redirected after interacting with steemconnect
stateString 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 usernameString 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 usernamesArray.<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 authorString 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 votesArray.<JSON> array containing the comments
orderByString default EasySteem.ORDER_OPTIONS.PAYOUT but OLDEST, NEWEST, REPUTATION, PAYOUT available
-
orderVotes(votes, orderBy)
-
orders the votes
Parameters:
Name Type Description votesArray.<JSON> array containing the votes
orderByString 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 amountString 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 urlString 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 parentAuthorString parent author of the post or comment
parentPermlinkString parent permlink of the post or comment
titleString title of the post (empty for a comment)
bodyString markdown formatted body
tagsArray.<String> tags of the post
rewardOptionString null REWARD_OPTIONS.CENT_PERCENT_SP, REWARD_OPTIONS.FIFTY_PERCENT_SP_SBD or REWARD_OPTIONS.NONE
beneficiariesArray.<JSON> array containing the beneficiaries and the weight for their reward
jsonMetadataJSON metadata attached to this post
Returns:
Promise.<JSON> -return the transaction details
-
reblog(author, permlink) → {Promise.<JSON>}
-
reblog a post
Parameters:
Name Type Description authorString the author of the post to reblog
permlinkString 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 accessTokenString steemconnect oAuth2 access token
-
setAccount(account)
-
set the steem account that will be used to perform the actions
Parameters:
Name Type Description accountString steem account
-
sharesToSteem(rshares)
-
converts a number of shares into a number of Steem
Parameters:
Name Type Description rsharesNumber number of shares
Returns:
-the shares converted into a Steem value
-
unfollow(author) → {Promise.<JSON>}
-
unfollow an author
Parameters:
Name Type Description authorString 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 permlinkString permlink of the post or comment to comment
bodyString markdiwn formatted body
parentAuthorString null parent author of the post or comment to comment (if not provided, this will be retrieved via the Steem API)
parentPermlinkString 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 permlinkString permlink of the post to update
titleString title of the post
bodyString markdown formatted body
tagsArray.<String> tags of the post
jsonMetadataJSON metadata attached to this post
categoryString 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 metadataJSON Returns:
Promise.<JSON> -return the transaction details
-
upvote(postAuthor, postPermlink, weigth) → {Promise.<JSON>}
-
upvote a post
Parameters:
Name Type Description postAuthorString the username of the author of the post
postPermlinkString the permlink of the post
weigthNumber 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 vestingSharesNumber totalVestingSharesNumber totalVestingFundSteemNumber