Skip to content

WheelerLee/xuper-sdk-js

 
 

Repository files navigation

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

  • Browser depends on window.crypto
  • Nodejs >= v10.0
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

service name link state
Create account create LINK
Retrieve account retrieve LINK
Import private key import LINK
Export private key export LINK
Chekc address checkAddress LINK
Check mnemonic checkMnemonic LINK
Balance getBalance LINK
Balance Detail getBalanceDetail LINK

Blockchain infomation

service name link state
Blockchains getBlockChains LINK
Status checkStatus LINK
Block by id getBlockById LINK
Block by height getBlockByHeight LINK

Transaction

service name link state
Make transfer transfer LINK
Post tx postTransaction LINK
Query tx queryTransaction LINK

Contract

service name link state
New contract account createContractAccount LINK
Contract list getContracts LINK
Deploy Wasm contract deployWasmContract LINK
Invoke Wasm contarct invokeContarct LINK
Deploy Solidity contract deploySolidityContract LINK
Invoke Solidity contarct invokeSolidityContarct LINK
Deploy Native contract deployNativeContract LINK
Invoke Native contarct invokeContarct LINK
Query ACL queryACL LINK
Query stat data about contract queryContractStatData LINK

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
        })
    ]
});

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 95.9%
  • JavaScript 4.1%