Options
All
  • Public
  • Public/Protected
  • All
Menu

NULS-JS Build Status npm version Coverage Status

Isomorphic JavaScript SDK for NULS blockchain.

Warning

This project is still in early development stages. It is strongly not recommended to use this in a production environment.

Install

$ npm i nuls-js

Usage

import NULS from 'nuls-js';

const account = NULS.account.create(); // Initiate a new account

console.log(account.address); // Nse1TYHc6Rxs84iimrnygSF2kqrUAQM6

Guide

https://CCC-NULS.github.io/nuls-js/

Documentation

https://CCC-NULS.github.io/nuls-js/typedoc/index.html

Features

Account Management

TODO

  • Read an address balance
  • Read node details
  • Read address transactions
    • Token transactions
    • Node joining/leaving
    • Node reward output/input
    • Red/yellow card transactions
  • Send a transaction
  • Find all consensus nodes
  • Find all nodes
  • Find richList/mostActive addresses
  • Recent transactions

License

See the LICENSE file for details.

Index

Enumerations

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

Address

Address: string

AddressHash

AddressHash: Buffer

AgentHash

AgentHash: Hash

BlockHash

BlockHash: string

BlockHex

BlockHex: string

CoinDataData

CoinDataData: ICoinDataData | null
Len Fields Data Type Remark
?? inputsSize VarInt
?? inputs Coin[] list of coins
?? outputsSize VarInt
?? outputs Coin[] list of coins

CoinObject

ContractCallArg

ContractCallArg: string | string[]

ContractCallArgs

ContractCallArgs: ContractCallArg[]

ContractMethodsArgCustomType

ContractMethodsArgCustomType: string

ContractMethodsArgType

ContractMethodsArgType: "String" | "double" | "long" | "int" | "boolean" | "Address" | "BigInteger"

ContractMethodsRetType

ContractMethodsRetType: ContractMethodsArgType | ContractMethodsArgCustomType | "void"

Hash

Hash: string

IContractCallGasResponse

IContractCallGasResponse: number

IContractGetMethodsResponse

IContractGetMethodsResponse: IContractMethod[]

IContractViewResponse

IContractViewResponse: string

IDigestData

IDigestData: INulsDigestDataData

INulsDataData

INulsDataData: Buffer | null

NulsData

Checks if the serialized data is null and reads / writes a placeholder

INulsSignData

INulsSignData: INulsSignDataData

IP2PHKSignature

IP2PHKSignature: IP2PKHScriptSigData

ITxDataData

Len Fields Data Type Remark
?? txData ?? Transaction data

ITxDataDataData

ITxDataDataData: IVarByteData

TxDataData

TX_TYPE_DATA

尺寸 字段 数据类型 说明
?? logicData byte[] business data

ITxDataDataOutput

ITxDataDataOutput: IVarByteOutput

ITxDataRewardData

ITxDataRewardData: Buffer

TX_TYPE_COINBASE

尺寸 字段 数据类型 说明
?? txData byte[] 0xFFFFFFFF

ITxDataTransferData

ITxDataTransferData: ITxDataRewardData

TX_TYPE_TRANSFER

尺寸 字段 数据类型 说明
?? txData byte[] 0xFFFFFFFF

ITxDataTransferOutput

ITxDataTransferOutput: ITxDataRewardOutput

IVarByteData

IVarByteData: Buffer

Variable-length buffer, consistent with the VarString implementation.

Len Fields Data Type Remark
? length VarInt 字符串的长度,以字节为单位
length data byte[length] 字符串本身

SignatureHash

SignatureHash: Buffer

TransactionClass

TransactionHash

TransactionHash: string

TransactionHex

TransactionHex: string

TransactionReceipt

TransactionReceipt: ApiTransaction

TransactionStaticClass

TransactionStaticClass: BaseTransaction

Variables

Const ADDRESS_LENGTH

ADDRESS_LENGTH: 23 = 23

Const BLACK_HOLE_ADDRESS

BLACK_HOLE_ADDRESS: "Nse5FeeiYk1opxdc5RqYpEWkiUDGNuLs" = "Nse5FeeiYk1opxdc5RqYpEWkiUDGNuLs"

Const CONSENSUS_LOCK_TIME

CONSENSUS_LOCK_TIME: -1 = -1

Const CONSTRUCTOR_METHOD_NAME

CONSTRUCTOR_METHOD_NAME: "<init>" = "<init>"

Const CONTRACT_MAX_GAS_LIMIT

CONTRACT_MAX_GAS_LIMIT: 10000000 = 10000000

Const CONTRACT_MIN_GAS_PRICE

CONTRACT_MIN_GAS_PRICE: 25 = 25

Const HASH_LENGTH

HASH_LENGTH: 34 = 34

Const MAX_FEE_PRICE_1024_BYTES

MAX_FEE_PRICE_1024_BYTES: 1000000 = 1000000

Const MIN_FEE_PRICE_1024_BYTES

MIN_FEE_PRICE_1024_BYTES: 100000 = 100000

Const NULS_BASE

NULS_BASE: number = 10**8

Const NULS_DECIMALS

NULS_DECIMALS: 8 = 8

Const P2SH_ADDRESS_TYPE

P2SH_ADDRESS_TYPE: 3 = 3

Const PLACE_HOLDER

PLACE_HOLDER: Buffer = Buffer.from([0xFF, 0xFF, 0xFF, 0xFF])

Const PRIVATE_KEY_LENGTH

PRIVATE_KEY_LENGTH: 64 = 64

Const QRCode

QRCode: QRCodeClass = new QRCodeClass()

Functions

addressFromHash

createBlockSignature

createTransactionSignature

getFee

  • getFee(size: number, feePrice: number): number
  • According to the transaction size calculate the handling fee

    Parameters

    • size: number

      size of the transaction

    • feePrice: number

      price of the fee per block (1KB)

    Returns number

getMaxFee

  • getMaxFee(size: number): number
  • Retrieves the maximun fee for the given transaction size

    Parameters

    • size: number

      size of the transaction

    Returns number

getMinFee

  • getMinFee(size: number): number
  • Retrieves the minimum fee for the given transaction size

    Parameters

    • size: number

      size of the transaction

    Returns number

getPrivateKeyBuffer

  • getPrivateKeyBuffer(privateKey: string): Buffer

getSignatureFromHash

getSignatureHash

getXOR

  • getXOR(bytes: Buffer): number

hashFromAddress

hashFromPublicKey

  • hashFromPublicKey(publicKey: Buffer, __namedParameters?: object): Buffer

isHex

  • isHex(input: string): boolean

isValidAddress

  • isValidAddress(address: string): boolean

isValidHash

  • isValidHash(hash: string): boolean

isValidPrivateKey

  • isValidPrivateKey(privateKey: string): boolean

naToNuls

  • naToNuls(na: number): number

nulsToNa

  • nulsToNa(nuls: number): number

publicKeyFromPrivateKey

  • publicKeyFromPrivateKey(privateKey: Buffer): Buffer

readUint64LE

  • readUint64LE(buffer: Buffer, offset: number): number

ripemd160

  • ripemd160(buffer: Buffer): Buffer

sha256

  • sha256(buffer: Buffer): Buffer

sha256Twice

  • sha256Twice(buffer: Buffer): Buffer

writeUint64LE

  • writeUint64LE(data: number, buf: Buffer, offset: number): number