Through this library you can interact with a RISE node in an easy way. The library works both in the browser and Node.js.
All available methods are available in the jsdoc
Either download dist/browser/index.js
or use gitcdn as follows:
<script type="text/javascript" src="https://unpkg.com/risejs/dist/browser/index.js"></script>
npm i risjes -D
var mainnet = require('risejs').rise;
var testnet = require('risejs').trise;
var custom = require('risejs').dposAPI.newWrapper('http://example.com:5566');
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. Be aware that all the methods sending a secret over the network are going to be deprecated:
dposAPI.accounts.getAccount('123456R', function(error, account) {
if (!error) {
// yay!
console.log(account);
} else {
console.log('error: ', error);
}
// ...
});
or
rise.accounts.getAccount('123456R')
.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));
In some cases you need to connect to multiple nodes.
To do so, just use the newWrapper method: