An open API service indexing awesome lists of open source software.

https://github.com/zoobc/zoobc-sdk

Small set of libraries written with TypeScript and compiled to be JavaScript, making it easy to implement / integrate applications so that they connect with the P2P API of the nodes in the blockchain for the Web API of the explorer servers and wallet.
https://github.com/zoobc/zoobc-sdk

blockchain grpc grpc-web javascript typescript

Last synced: 9 months ago
JSON representation

Small set of libraries written with TypeScript and compiled to be JavaScript, making it easy to implement / integrate applications so that they connect with the P2P API of the nodes in the blockchain for the Web API of the explorer servers and wallet.

Awesome Lists containing this project

README

          

![Screenshot](assets/images/ZooBC-SDK.gif)

# ZooBC-SDK

![npm](https://img.shields.io/npm/v/zoobc)
![download](https://img.shields.io/npm/dw/zoobc)
![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)
![build](https://img.shields.io/circleci/build/github/zoobc/zoobc-sdk?token=8a1610a487c652b7165e501f7d4c814fe0e34e12)

ZooBC-SDK is a small set of libraries written with TypeScript and compiled to be JavaScript, making it easy to implement / integrate applications so that they connect with the P2P API of the nodes in the blockchain for the Web API of the explorer servers and wallet.

## Start using ZooBC-SDK

For instructions on how to use web and mobile for a project, please refer to these documents:

- [AngularJs](examples/angular)
- [Ionic](examples/ionic)
- [ReactJs](examples/react)
- [React Native](https://github.com/zoobc/zoobc-thumbwar.git)
- [VueJs](examples/vue)

## General Usage

Add 'zbc-sdk' packages to your project by executing:

```bash
$ npm install zbc-sdk
or
$ yarn add zbc-sdk
```

Here's an example of basic usage for connection:

```bash
import React, { useState, useEffect } from 'react';
import zoobc from 'zbc-sdk';

const App = () => {
const [blocks, setBlocks] = useState([])
const [error, setError] = useState(null)
const [detail, setDetail] = useState(null)

useEffect(() => {
const hosts = [
{ host: 'http://your-ip-address:your-port', name: 'Testnet' },
];
zoobc.Network.list(hosts)
listBlocks();
}, [])

const listBlocks = () => {
zoobc.Block
.getBlocks({height: 0})
.then(res => setBlocks(res.blocksList))
.catch(err => setError(err))
};

const onClickBlockId = (id) => {
zoobc.Block
.getBlockById(id)
.then(res => {
setDetail(res)
setError(null)
})
.catch(err => {
setError(err)
setDetail(null)
})
}

const onClickBlockHeight = (height) => {
zoobc.Block
.getBlockByHeight(height)
.then(res => {
setDetail(res)
setError(null)
})
.catch(err => {
setError(err)
setDetail(null)
})
}

return (
<>
{!!error && (
<>

Error

{JSON.stringify(error)}
>
)}{!!detail && (
<>
Detail

{JSON.stringify(detail)}
>
)}



Id
Previous Hash
Height
Timestamp
Version



{blocks.length > 0 &&
blocks.map((data, key) => {
return (

onClickBlockId(data.block.id)}>
{data.block.id}

{data.block.previousblockhash}
onClickBlockHeight(data.block.height)}>
{data.block.height}

{data.block.timestamp}
{data.block.version}

);
})}


>
)
}

export default App;
```

## Contributors

Thanks to all who have [contributed](https://github.com/zoobc/zoobc-sdk/graphs/contributors) to ZooBC-SDK!





Gungde






Eko






Irfan






Yandi






Nata






Bagas






Kevin






Adhiim






Witarsana

## License

This project is licensed under the Apache License - see the [LICENSE](LICENSE) file for details