Skip to content

API written in TypeScript/JavaScript to interact with the RISE blockchain

License

Notifications You must be signed in to change notification settings

RiseVision/rise-ts-old

Repository files navigation

npm

Rise Javascript Library

Through this sdk you can interact with a rise node in an easy way. The library works both in the browser and Node.js.

Documentation

All available methods are available in the jsdoc

Quick Start

Include the library in your browser.

Either download dist/browser/index.js or use gitcdn as follows:

<script type="text/javascript" src="https://gitcdn.xyz/cdn/risevision/rise-js-sdk/master/dist/browser/index.js"></script>
<script>
  rise.nodeAddress = 'http://example.com:5566'; // Set your node url here. (no leading slash)
  // If you don't have a nodejust use https://wallet.rise.vision
  // ...
</script>

Include it with npm (Suitable also for webpack/browserify)

npm i risejs -D
var rise = require('risejs').rise;
rise.nodeAddress= 'http://example.com:5566'; // Set your node url here. (no leading slash) 

Compatibility

Browser Support

Chrome Firefox Safari Opera Edge IE
Latest ✔ Latest ✔ Latest ✔ Latest ✔ Latest ✔ 8+ ✔

Browser Matrix

Node support

Node >= 4.x is fully supported :)

Examples

All the APIs are designed to be easy to use. You can use both Callbacks or Promises; you decide.

For example you can open a new account by doing:

rise.accounts.open('secret', function(error, account) {
  if (!error) {
    // yay!
    console.log(account);
  } else {
    console.log('error: ', error);
  }
  // ...
});

or

rise.accounts.open('secret')
    .then(function (account) {
      console.log(account);
    })
    .catch(function (error) {
      console.log('error: ', error);
    });

which can be even shorter if you write your code in TypeScript or ES6

rise.accounts.open('secret')
    .then(console.log)
    .catch(error => console.log('error: ', error));

Advanced Usage

In some cases you need to connect to multiple nodes.

To do so, just use the newWrapper method:

var node1 = rise.newWrapper('http://node1:1234');
var node2 = rise.newWrapper('http://node2:1234');

// interact with node1 & node2 using the same APIs available within 'rise' variable.

Where is this library used?

The library is currently used in the following projects: