Steem.js the official JavaScript library for Steem blockchain
Steem.js
Steem.js the JavaScript API for Steem blockchainDocumentation
- Subscriptions - Tags - Blocks and transactions - Globals - Keys - Accounts - Market - Authority / validation - Votes - Content - WitnessesHere is full documentation: https://github.com/steemit/steem-js/tree/master/doc
Browser
CDN
https://cdn.jsdelivr.net/npm/steem/dist/steem.min.js
Webpack
Please have a look at the webpack usage example.Server
Install
$ npm install steem --save
RPC Servers
https://api.steemit.com By DefaultExamples
Broadcast Vote
var steem = require('steem');
var wif = steem.auth.toWif(username, password, 'posting'); steem.broadcast.vote(wif, voter, author, permlink, weight, function(err, result) { console.log(err, result); });
Broadcast Vote with Promises
var steem = require('steem');
var wif = steem.auth.toWif(username, password, 'posting'); // Using Promises steem.broadcast.vote(wif, voter, author, permlink, weight) .then(result => console.log(result)) .catch(error => console.error(error));
// Or using async/await async function castVote() { try { const result = await steem.broadcast.vote(wif, voter, author, permlink, weight); console.log(result); } catch (error) { console.error(error); } }
Get Accounts
steem.api.getAccounts(['ned', 'dan'], function(err, result) {
console.log(err, result);
});
Get State
steem.api.getState('/trends/funny', function(err, result) {
console.log(err, result);
});
Reputation Formatter
var reputation = steem.formatter.reputation(user.reputation);
console.log(reputation);
Steem Testnet
Steem-js requires some configuration to work on the public Steem testnet.You need to set two Steem API options, addressprefix and chainid.
steem.api.setOptions({ address_prefix: 'TST', chain_id: '46d82ab7d8db682eb1959aed0ada039a6d49afa1602491f93dde9cac3e8e6c32', useTestNet: true, });
The Chain ID could change. If it does, it may not be reflected here, but will be documented on any testnet launch announcements.