https://github.com/bonuschain/byteball.js
Today we are proud to bring you the beta release of Byteball.js!
Byteball.js is a JavaScript library that allow you to interact with a Byteball node. It was designed to work both in the browser and in Node.js. If you are familiar to Steem.js you will quickly understand how Byteball.js works, both of these libraries serve the same purpose but they are just made for a different chain.
Here are some cool things you can do today using Byteball.js:
To install Byteball.js on Node.js, open your terminal and run:
npm i byteball --save
You can also create an index.html file and include Byteball.js script to use it on your browser like this:
<script src="https://cdn.jsdelivr.net/npm/byteball"></script>
Here is how to initiate the client:
const byteball = require('byteball');
const client = new byteball.Client();
All API methods follow this pattern:
// If the last argument is a function it is treated as a callback
client.api.getJoint('oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=', function(err, result) {
console.log(err, result);
});
// If a callback is not provided, a Promise is returned
client.api.getJoint('oj8yEksX9Ubq7lLc+p6F2uyHUuynugeVq4+ikT67X6E=').then(function(result) {
console.log(result);
});
To compose and post unit you need first to create a Byteball wallet and fund it with the native currency ‘bytes’. The generated WIF will be used on Byteball.js. Click on this link to learn more: https://byteballjs.com/utils/generate-wallet
Here is how to make a payment:
const wif = '5JBFvTeSY5...'; // WIF string generated (private key)
const params = {
outputs: [
{
address: 'NX2BTV43XN6BOTCYZUUFU6TK7DVOC4LU', // The Byteball address of the recipient
amount: 1000 // The amount he receives
}
]
};
client.post.payment(params, wif, function(err, result) {
console.log(result); // The unit hash is returned
});
You can find the current documentation for Byteball.js at https://byteballjs.com
Byteball.js code is entirely open source with a MIT license. You are welcome to contribute on the project by opening issues and pull requests on the GitHub repo here: https://github.com/bonuschain/byteball.js
In the next few months we are going to implement new features on Byteball.js like these:
Got some ideas, questions or feedbacks you want talk about? We would love to hear from you, join the discussion here or on Byteball Slack channel #byteball-js. Click here to get invited: https://slack.byteball.org.
We would like to thank Byteball trustees who voted to fund this project and also Utopian for helping open source projects like Byteball.js.