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 | 简体中文
npm install --save @xuperchain/xuper-sdk
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();
- 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
}
}
})
Read the documentation , compile and deploy XuperChain
- Pull image (XuperChian v3.7 - Repository)
docker pull smilingxinyi/xuperchain
- Start container
docker run -d -p 8098:8098 -p 37101:37101 -p 47101:47101 --name xc smilingxinyi/xuperchain
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 | √ |
service | name | link | state |
---|---|---|---|
Blockchains | getBlockChains | LINK | √ |
Status | checkStatus | LINK | √ |
Block by id | getBlockById | LINK | √ |
Block by height | getBlockByHeight | LINK | √ |
service | name | link | state |
---|---|---|---|
Make transfer | transfer | LINK | √ |
Post tx | postTransaction | LINK | √ |
Query tx | queryTransaction | LINK | √ |
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 | √ |
The plugin must be used on the
public network
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
})
]
});