Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bonustrack/obyte.js
A pure and powerful JavaScript Obyte library.
https://github.com/bonustrack/obyte.js
api byteball dag javascript obyte oscript
Last synced: 15 days ago
JSON representation
A pure and powerful JavaScript Obyte library.
- Host: GitHub
- URL: https://github.com/bonustrack/obyte.js
- Owner: bonustrack
- License: mit
- Created: 2017-03-09T20:31:27.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-07T22:58:32.000Z (almost 2 years ago)
- Last Synced: 2024-10-21T08:58:46.101Z (16 days ago)
- Topics: api, byteball, dag, javascript, obyte, oscript
- Language: JavaScript
- Homepage: https://obytejs.com
- Size: 2.72 MB
- Stars: 27
- Watchers: 5
- Forks: 10
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Contributing: docs/CONTRIBUTING.md
- License: LICENSE
- Code of conduct: docs/CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![npm](https://img.shields.io/npm/v/obyte.svg)](https://www.npmjs.com/package/obyte)
![npm](https://img.shields.io/npm/dm/obyte.svg)
![CircleCI](https://img.shields.io/circleci/project/github/bonustrack/obyte.js.svg)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/bonustrack/obyte.js/master/LICENSE)# Obyte.js
A pure and powerful JavaScript Obyte library.
**[Documentation](https://obytejs.com)**
## 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:
```html
```
### Usage
Ways to initiate WebSocket client:
```js
const obyte = require('obyte');// Connect to mainnet official node 'wss://obyte.org/bb'
const client = new obyte.Client();// Connect to a custom node
const client = new obyte.Client('wss://obyte.org/bb');// Connect to testnet
const options = { testnet: true };
const client = new obyte.Client('wss://obyte.org/bb-test', options);
```Close the client:
```js
client.close();
```All API methods follow this pattern:
```js
// 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 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](https://obytejs.com/utils/generate-wallet)
Sending a payment:
```js
const wif = '5JBFvTeSY5...'; // WIF string generated (private key)const params = {
outputs: [
{
address: 'NX2BTV43XN6BOTCYZUUFU6TK7DVOC4LU', // The Obyte 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
});
```## License
[MIT](LICENSE).