Home

Awesome

Xuper SDK JS

Build Status npm version

Xuper SDK (JS/TS) is a software development kit that allows developers to quickly use XuperChain.

The SDK provides a service interface that includes account, transaction, contract and various query functions. It can be used in a browser and Nodejs environment.


English | 简体中文

Usage

Install Npm package

npm install --save @xuperchain/xuper-sdk

Quick start

import XuperSDK from '@xuperchain/xuper-sdk';

const node = ''; // node
const chain = ''; // chain

const xsdk = XuperSDK.getInstance({
    node,
    chain
});

const start = async () => {
    const result = await xsdk.getBlockChains();
    console.log(result);
};

start();

Details - API reference

Code examples

Edit xuper-sdk-demo

Environments

In the Nodejs environment, gRPC is supported and used by default, you can choose to close it, and still use Http to request
XuperSDK.getInstance({
    ...,
    env: {
        node: {
            disableGRPC: true // disable gRPC
        }
    }
})

How to build a test environment

Read the documentation , compile and deploy XuperChain

Use XuperChain Docker image to build a single-node service

  1. Pull image (XuperChian v3.7 - Repository)

docker pull smilingxinyi/xuperchain

  1. Start container

docker run -d -p 8098:8098 -p 37101:37101 -p 47101:47101 --name xc smilingxinyi/xuperchain

API reference documentation

Link

Services

Account

servicenamelinkstate
Create accountcreateLINK
Retrieve accountretrieveLINK
Import private keyimportLINK
Export private keyexportLINK
Chekc addresscheckAddressLINK
Check mnemoniccheckMnemonicLINK
BalancegetBalanceLINK
Balance DetailgetBalanceDetailLINK

Blockchain infomation

servicenamelinkstate
BlockchainsgetBlockChainsLINK
StatuscheckStatusLINK
Block by idgetBlockByIdLINK
Block by heightgetBlockByHeightLINK

Transaction

servicenamelinkstate
Make transfertransferLINK
Post txpostTransactionLINK
Query txqueryTransactionLINK

Contract

servicenamelinkstate
New contract accountcreateContractAccountLINK
Contract listgetContractsLINK
Deploy Wasm contractdeployWasmContractLINK
Invoke Wasm contarctinvokeContarctLINK
Deploy Solidity contractdeploySolidityContractLINK
Invoke Solidity contarctinvokeSolidityContarctLINK
Deploy Native contractdeployNativeContractLINK
Invoke Native contarctinvokeContarctLINK
Query ACLqueryACLLINK
Query stat data about contractqueryContractStatDataLINK

Plugin

Endorsement service plugin

The plugin must be used on the public network

EndorsementPlugin

Example:


const params = {
    server: process.env.ENDORSE_SERVER, // ip, port
    fee: process.env.FEE, // fee
    endorseServiceCheckAddr: process.env.SERVICE_SIGN_ADDRESS, // sign address
    endorseServiceFeeAddr: process.env.SERVICE_FEE_ADDRESS // fee address
}

const xsdk = new XuperSDK({
    node,
    chain,
    plugins: [
        EndorsementPlugin({
            transfer: params,
            makeTransaction: params
        })
    ]
});