Obyte.js
A pure and powerful JavaScript Obyte library.
Documentation
Getting started
To install and run Obyte.js, follow this quick start guide
Install
Obyte.js was designed to work both in the browser and in Node.js.
Node.js
To install Obyte.js on Node.js, open your terminal and run:
npm i obyte --save
Browser
You can create an index.html file and include Obyte.js with:
<script src="https://cdn.jsdelivr.net/npm/obyte"></script>
Usage
Ways to initiate WebSocket client:
const obyte = require('obyte');
const client = new obyte.Client();
const client = new obyte.Client('wss://obyte.org/bb');
const options = { testnet: true };
const client = new obyte.Client('wss://obyte.org/bb-test', options);
Close the client:
client.close();
All API methods follow this pattern:
client.api.getJoint('oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=', function(err, result) {
console.log(err, result);
});
client.api.getJoint('oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=').then(function(result) {
console.log(result);
});
Transaction
To compose and post unit you need first to create a Obyte wallet and fund it with the native currency ‘bytes’. The generated WIF will be used on Obyte.js. Click on the link below to learn more:
Generate a random address
Sending a payment:
const wif = '5JBFvTeSY5...';
const params = {
outputs: [
{
address: 'NX2BTV43XN6BOTCYZUUFU6TK7DVOC4LU',
amount: 1000
}
]
};
client.post.payment(params, wif, function(err, result) {
console.log(result);
});
License
MIT.