osb-cli-sdk
OASISBloc Client SDK connecting blockchain, IDFS network to share data
Last updated 8 months ago by renovj .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install osb-cli-sdk 
SYNC missed versions from official npm registry.

npm package of OASISBloc client sdk for js

OASISBloc supports JavaScript SDK for 3rd party or user services development. You can integrate OASISBloc JavaScript SDK into your project and utilize OASISBloc Data Trade protocol’s functionality. This document provides you with an information of installation and API specification.

Installation

Usage in Node.js

Install osb-cli-sdk module using npm.

npm install --save osb-cli-sdk

Import osb-cli-sdk module.

import OASIS_CLI from 'osb-cli-sdk'

API Specification

OASIS_CLI is a root class of osb-cli-sdk, which provides APIs to communicate with OASISBloc blockchain nodes and IDFS nodes. The details of the APIs are as below:

Constructor

Creating an instance of oasisbloc client

const config = {
    chainAccessPoint: [BLOCKCHAIN_API_NODE_ENDPOINT],
    chainId: [BLOCKCHAIN_ID],
    dataTradeContractName: [DATA_TRADE_CONTRACT_NAME],
    privateKey: [PRIVATE_KEY_OF_USER],
    account: [ACCOUNT_NAME_OF_USER]
}
const osbClient = new OASIS_CLI(config)

Parameters

Parameter Type Description
config.chainAccessPoint string Blockchain API node endpoint (ex: 'http://18.141.2.126:1387')
config.chainId string Blockchain id (ex: '2cfbbc1ce6f7c4a48cfbb6de6ad00c55ea21401fbcf983a6f553fb4d8923d695')
config.dataTradeContractName string Data trade contract name (ex: 'datatrade13')
config.privateKey string User's private key
config.account string User's account name

setAuthForContract

데이터 거래를 통해 자산 이동 발생에 대한 동의

osbClient.setAuthForContract()

registerData

Registering a data to oasisbloc with encryption and fragmentation of data, and uploading data to data keeper's IDFS nodes

osbClient.registerData(data, datatypename, detailFields, price, period, decryptKeyList)

Parameters

Parameter Type Description
data Buffer Data buffer to register
datatypename string Datatype name
detailFields string array Values for each metadata field of the datatype
price string Data price (OSB)
period integer Data provide period (days)
decryptKeyList string array Private key list for encrypting each data fragment. The number of data fragments is set from the length of this list

Return values

Return value Type Description
txResultAddDataBegin object Transaction result data of adddatabegin action
txResultAddDataEnd object Transaction result data of adddataend action
dataRegistrationInfo object Data registration information

buyData

Getting a data access authority

osbClient.buyData(dataid, buyerPrivateKey)

Parameters

Parameter Type Description
dataid integer Data registration id
buyerPrivateKey string Buyer private key for authentication of data access. It is not the private key of the user account

Return values

Return value Type Description
txResultBuyData object Transaction result data of buydata action
dataBuyHistoryInfo object Data buy information

requestData

Downloading encrypted data fragments

osbClient.requestData(dataid, buyid, buyerPrivateKey)

Parameters

Parameter Type Description
dataid integer Data registration id
buyid integer Data purchase id
buyerPrivateKey string Buyer private key for authentication of data access. It is not the private key of the user account

Return values

Return value Type Description
data Buffer The purchased data

Current Tags

  • 0.0.12                                ...           latest (8 months ago)

12 Versions

  • 0.0.12                                ...           8 months ago
  • 0.0.11                                ...           8 months ago
  • 0.0.10                                ...           8 months ago
  • 0.0.9                                ...           8 months ago
  • 0.0.8                                ...           8 months ago
  • 0.0.7                                ...           8 months ago
  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (7)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |