0.0.12 • Published 4 years ago

osb-cli-sdk v0.0.12

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

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

ParameterTypeDescription
config.chainAccessPointstringBlockchain API node endpoint (ex: 'http://18.141.2.126:1387')
config.chainIdstringBlockchain id (ex: '2cfbbc1ce6f7c4a48cfbb6de6ad00c55ea21401fbcf983a6f553fb4d8923d695')
config.dataTradeContractNamestringData trade contract name (ex: 'datatrade13')
config.privateKeystringUser's private key
config.accountstringUser'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

ParameterTypeDescription
dataBufferData buffer to register
datatypenamestringDatatype name
detailFieldsstring arrayValues for each metadata field of the datatype
pricestringData price (OSB)
periodintegerData provide period (days)
decryptKeyListstring arrayPrivate key list for encrypting each data fragment. The number of data fragments is set from the length of this list

Return values

Return valueTypeDescription
txResultAddDataBeginobjectTransaction result data of adddatabegin action
txResultAddDataEndobjectTransaction result data of adddataend action
dataRegistrationInfoobjectData registration information

buyData

Getting a data access authority

osbClient.buyData(dataid, buyerPrivateKey)

Parameters

ParameterTypeDescription
dataidintegerData registration id
buyerPrivateKeystringBuyer private key for authentication of data access. It is not the private key of the user account

Return values

Return valueTypeDescription
txResultBuyDataobjectTransaction result data of buydata action
dataBuyHistoryInfoobjectData buy information

requestData

Downloading encrypted data fragments

osbClient.requestData(dataid, buyid, buyerPrivateKey)

Parameters

ParameterTypeDescription
dataidintegerData registration id
buyidintegerData purchase id
buyerPrivateKeystringBuyer private key for authentication of data access. It is not the private key of the user account

Return values

Return valueTypeDescription
dataBufferThe purchased data
0.0.12

4 years ago

0.0.10

4 years ago

0.0.11

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago