New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

zbc-sdk

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zbc-sdk

A small set of libraries to implement applications connect with the P2P API of the nodes in the blockchain

latest
Source
npmnpm
Version
0.0.30-pre-release
Version published
Weekly downloads
7
-75.86%
Maintainers
1
Weekly downloads
 
Created
Source

Screenshot

ZooBC-SDK

npm download license build

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
  • Ionic
  • ReactJs
  • React Native
  • VueJs

General Usage

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

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

Here's an example of basic usage for connection:

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 && (
        <>
          <div><strong>Error</strong></div>
          <code>{JSON.stringify(error)}</code>
        </>
      )}{!!detail && (
        <>
          <div><strong>Detail</strong></div>
          <code>{JSON.stringify(detail)}</code>
        </>
      )}
        <table>
          <thead>
            <tr>
              <th>Id</th>
              <th>Previous Hash</th>
              <th>Height</th>
              <th>Timestamp</th>
              <th>Version</th>
            </tr>
          </thead>
          <tbody>
            {blocks.length > 0 &&
              blocks.map((data, key) => {
                return (
                  <tr key={key}>
                    <td onClick={() => onClickBlockId(data.block.id)}>
                      {data.block.id}
                    </td>
                    <td>{data.block.previousblockhash}</td>
                    <td onClick={() => onClickBlockHeight(data.block.height)}>
                      {data.block.height}
                    </td>
                    <td>{data.block.timestamp}</td>
                    <td>{data.block.version}</td>
                  </tr>
                );
              })}
          </tbody>
        </table>
      </>
  )
}

export default App;

Contributors

Thanks to all who have contributed to ZooBC-SDK!


Gungde

Eko

Irfan

Yandi

Nata

Bagas

Kevin

Adhiim

Witarsana

License

This project is licensed under the Apache License - see the LICENSE file for details

Keywords

blockchain

FAQs

Package last updated on 22 Mar 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts