0.11.6 • Published 4 years ago

heix-sdk v0.11.6

Weekly downloads
2
License
ISC
Repository
-
Last release
4 years ago

How to install

Method one:

Using SDK for your coding.

npm i heix-sdk --save

// NOTE: test production environment
const { _SDK } = require('heix-sdk')('production');

// NOTE: test qa environment
const { _SDK } = require('heix-sdk')('qa');

// NOTE: test development environment
const { _SDK } = require('heix-sdk')();

const secret = your_secret_key
const issuerPublic = issuer_public_key
const licence = your_jwt_licence

const sdk = _SDK.init(secret, issuerPublic, licence);

const result = await sdk.RequestAuditedTokenTxn(obj);

HOW to USE these api

Before start

It is welcome to use Heix-sdk. All you need to do is applying JWT token from BTCARD Inc. We will give you instrucation about how to use BA (Blockchain Authentication) to active your public key and join our network.

Please email to us: service@btcard.com

INIT

const result = await sdk.init(secret, issuerPublic,licence);

TrustAuditedTokenTxn

const obj = {
    token: @string,  // example: 'USDB'
    issue: @string

}
const result = await sdk.TrustAuditedTokenTxn(obj);

RequestAuditedTokenTxn

const obj = {
    total: @number,
    token: @string,
    alloc: [{
        address: @string,,
        amount: @number
    }]
}
const result = await sdk.RequestAuditedTokenTxn(obj);

ApproveAuditedTokenTxn

const result = await sdk.ApproveAuditedTokenTxn(envelope);

SendAuditedTokenTxn

const obj = {
   tokenID: @string,
   amount: @number,
   to: @address,
   docs: @array[] //目前無功能
}
const result = await sdk.SendAuditedTokenTxn(obj);

AuditedDocument

// if one or many issuers are signing one contract.
const issuers = [issuer1 issuer2, ...]
const result = await sdk.AuditedDocument(issuers, docHash, memo);

GetTokenBalance

const obj = {
   address:@string,
   tokenID: @string,
   licence:@jwt
}
const result = await sdk.GetTokenBalance(address:@string, tokenID: @string,licence:@jwt);

GetTransationByHash

const obj = {
   hash:@string,
   licence:@jwt
}
const result = await sdk.GetTransationByHash(obj);

DepositTokenTxn

const obj = {
   tokenID:@string,
   amount:@string |@number
   to:@string
}
const result = await sdk.DepositTokenTxn(obj);

SendMultiPayments

const obj = {
    payments:[{
    	token: @string,
        amount: @string,
        destination:@string
    }]
}
const result = await sdk.SendMultiPayments(obj);

Method Two:

Run as a server

npm i heix-sdk --save

// NOTE: test production environment
const { _SERVER } = require('heix-sdk')('production');

// NOTE: test qa environment
const { _SERVER } = require('heix-sdk')('qa');

// NOTE: test development environment
const { _SERVER } = require('heix-sdk')();

const arg = {
    port: 5000,
    issuer: issuer_public_key
}

await _SERVER(arg);

Then, you can use it as RESTful API

TrustAuditedTokenTxn

POST::http://localhost:5000/sdk/TrustAuditedTokenTxn
header: application/json
body:
{
    privateKey: your_secret_key,
    token: asset_name
}

RequestAuditedTokenTxn

POST::http://localhost:5000/sdk/RequestAuditedTokenTxn
header: application/json
body:
{
    privateKey: your_secret_key,
    total 1000,
    token: 'USD',  // your asset code
    alloc: [{
        address: your_public_key,
        amount: 999
    }]
}

ApproveAuditedTokenTxn

POST::http://localhost:5000/sdk/ApproveAuditedTokenTxn
header: application/json
body:
{
    privateKey: your_secret_key,
    envelope: envelope_base64
}

SendAuditedTokenTxn

POST::http://localhost:5000/sdk/SendAuditedTokenTxn
header: application/json
body:
{
   privateKey: your_secret_key,
   tokenID: 'USD',
   amount: 500,
   to: public_key,
   docs: @array[] //目前無功能
}

GetTokenBalance

POST::http://localhost:5000/sdk/GetTokenBalance
header: application/json
body {
   address:@string,
   tokenID: @string
}

GetTransationByHash

POST::http://localhost:5000/sdk/GetTransationByHash
header: application/json
body {
   hash:@string
}

DepositTokenTxn

POST::http://localhost:5000/sdk/DepositTokenTxn
header: application/json
body {
   tokenID: @string,
   amount: @string |@number
   to: @string
}

TradeReatFund

POST::http://localhost:5000/sdk/TradeReatFund
header: application/json
body {
    traderA: @string,
    traderB: @string,
    fund: @string,
    amount: @number
}

How to logging

step1. install filebeat

linux:

cd ~/
curl -L -O https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.3.1-linux-x86_64.tar.gz
tar xzvf filebeat-7.3.1-linux-x86_64.tar.gz
cd ~/filebeat-7.3.1-linux-x86_64 

step2. modify filebeat input path in filebeat.yml

    filebeat.inputs:

# Each - is an input. Most options can be set at the input level, so
# you can use different inputs for various configurations.
# Below are the input specific configurations.

- type: log

  # Change to true to enable this input configuration.
  enabled: true

  # Paths that should be crawled and fetched. Glob based paths.
  paths:
      - /YOUR SYSTEM HOME PATH/heix-sdk/sdk.log

step3. modify filebeat output path in filebeat.yml

    # choose elasticsearch or logstash for filebeat output
    #-------------------------- Elasticsearch output ------------------------------
    #output.elasticsearch:
    #   # Array of hosts to connect to.
    #hosts: ["elk.elandfintech.com:9200"]

    #----------------------------- Logstash output --------------------------------
    #output.logstash:
    # The Logstash hosts
    # index: elandfintech
    #hosts: ["elk.elandfintech.com:5044"]

step4. execute filebeat

    ./filebeat -c filebeat.yml -e
0.11.6

4 years ago

0.11.5

4 years ago

0.11.4

4 years ago

0.11.3

4 years ago

0.11.2

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.0

4 years ago

0.9.0

5 years ago

0.8.1

5 years ago

0.6.25

5 years ago

0.6.24

5 years ago

0.6.23

5 years ago

0.6.22

5 years ago

0.6.21

5 years ago

0.6.20

5 years ago

0.6.19

5 years ago

0.6.18

5 years ago

0.6.17

5 years ago

0.6.16

5 years ago

0.6.15

5 years ago

0.6.14

5 years ago

0.6.13

5 years ago

0.6.12

5 years ago

0.6.11

5 years ago

0.6.10

5 years ago

0.6.8

5 years ago

0.6.7

5 years ago

0.6.6

5 years ago

0.6.5

5 years ago

0.6.4

5 years ago

0.6.3

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.0

5 years ago