Repository
https://github.com/bonuschain/byteball.js
Today we are proud to bring you the beta release of Byteball.js!
What is it?
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.
What can you do with it?
Here are some cool things you can do today using Byteball.js:
- Spend bytes or others Byteball public asset.
- Create your own token, bind a smart contract on your token.
- Run an oracle service, post verifiable data on the chain that can be used by smart contracts.
- Work with attestations, build an attestor service or check attested addresses.
- Create polls and vote for them.
- Set your public profile.
- Post arbitrary data or text on the DAG.
Quick start
Install
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>
Usage
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);
});
Transaction
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
});
Documentation
You can find the current documentation for Byteball.js at https://byteballjs.com
How to contribute?
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
Roadmap
In the next few months we are going to implement new features on Byteball.js like these:
- Ability to broadcast smart contract
- Ability to verify attested private profile
- Ability to send private messages
- Ability to send private payment
Join the discussion
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.
Final words
We would like to thank Byteball trustees who voted to fund this project and also Utopian for helping open source projects like Byteball.js.