Difference between revisions of "Steem.js"

From Steem Center
Jump to: navigation, search
(Redirected page to Steemjs)
 
Line 1: Line 1:
#REDIRECT [[Steemjs]]
+
Steem.js is a javascript library that allows developers to communicate and transact on the STEEM blockchain easily. A lot of applications use SteemJS, and the steemit.chat channel #steemjs is pretty active if you are looking for help.
 +
 
 +
[https://github.com/steemit/steem-js/tree/master/doc GitHub source]
 +
 
 +
== Browser ==
 +
 
 +
<pre class="html">&lt;script src=&quot;./steem.min.js&quot;&gt;&lt;/script&gt;
 +
&lt;script&gt;
 +
steem.api.getAccounts(['ned', 'dan'], function(err, response){
 +
    console.log(err, response);
 +
});
 +
&lt;/script&gt;</pre>
 +
== CDN ==
 +
 
 +
https://cdn.steemjs.com/lib/latest/steem.min.js<br/>
 +
 
 +
<pre class="html">&lt;script src=&quot;//cdn.steemjs.com/lib/latest/steem.min.js&quot;&gt;&lt;/script&gt;</pre>
 +
== Webpack ==
 +
 
 +
[https://github.com/steemit/steem-js/blob/master/examples/webpack-example Please have a look at the webpack usage example.]
 +
 
 +
== Server ==
 +
 
 +
== Install ==
 +
 
 +
<pre>$ npm install steem --save</pre>
 +
== WebSockets ==
 +
 
 +
wss://steemd.steemit.com By Default<br/> wss://node.steem.ws<br/> wss://this.piston.rocks<br/>
 +
 
 +
== Examples ==
 +
 
 +
=== Broadcast Vote ===
 +
 
 +
<pre class="js">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);
 +
});</pre>
 +
=== Get Accounts ===
 +
 
 +
<pre class="js">steem.api.getAccounts(['ned', 'dan'], function(err, result) {
 +
    console.log(err, result);
 +
});</pre>
 +
=== Get State ===
 +
 
 +
<pre class="js">steem.api.getState('/trends/funny', function(err, result) {
 +
    console.log(err, result);
 +
});</pre>
 +
=== Reputation Formatter ===
 +
 
 +
<pre class="js">var reputation = steem.formatter.reputation(user.reputation);
 +
console.log(reputation);</pre>

Revision as of 11:53, 14 July 2017

Steem.js is a javascript library that allows developers to communicate and transact on the STEEM blockchain easily. A lot of applications use SteemJS, and the steemit.chat channel #steemjs is pretty active if you are looking for help.

GitHub source

Browser

<script src="./steem.min.js"></script>
<script>
steem.api.getAccounts(['ned', 'dan'], function(err, response){
    console.log(err, response);
});
</script>

CDN

https://cdn.steemjs.com/lib/latest/steem.min.js

<script src="//cdn.steemjs.com/lib/latest/steem.min.js"></script>

Webpack

Please have a look at the webpack usage example.

Server

Install

$ npm install steem --save

WebSockets

wss://steemd.steemit.com By Default
wss://node.steem.ws
wss://this.piston.rocks

Examples

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);
});

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);