Options
All
  • Public
  • Public/Protected
  • All
Menu

CodeChain JavaScript SDK

Index

Classes

Interfaces

Type aliases

Variables

Functions

Type aliases

Action

KeyType

KeyType: "asset" | "platform"

NetworkId

NetworkId: string

Transaction

Variables

Const RLP

RLP: any = require("rlp")

Functions

Const blake256

  • blake256(data: Buffer | string): string
  • Gets data's 256 bit blake hash.

    Parameters

    • data: Buffer | string

      buffer or hexadecimal string

    Returns string

    32 byte hexadecimal string

Const blake256WithKey

  • blake256WithKey(data: Buffer | string, key: Uint8Array): string
  • Gets data's 256 bit blake hash by using the key.

    Parameters

    • data: Buffer | string

      buffer or hexadecimal string

    • key: Uint8Array

    Returns string

    32 byte hexadecimal string

checkAmount

  • checkAmount(amount: U256 | number | string): void

checkAmountU64

  • checkAmountU64(amount: number): void

checkAssetTransferAddressRecipient

checkAssetType

  • checkAssetType(value: H256 | string): void

checkIndex

  • checkIndex(index: number): void

checkKey

  • checkKey(key: H512 | string): void

checkLockScript

  • checkLockScript(lockScript: Buffer): void

checkLockScriptHash

  • checkLockScriptHash(value: H256 | string): void

checkMetadata

  • checkMetadata(metadata: string): void

checkNetworkId

checkNonce

  • checkNonce(nonce: number): void

checkOwners

checkParameters

  • checkParameters(parameters: Buffer[]): void

checkPlatformAddressRecipient

checkRegistrar

checkShardId

  • checkShardId(shardId: number): void

checkTransactionHash

  • checkTransactionHash(value: H256 | string): void

checkTransactions

checkTransferBurns

checkTransferInputs

checkTransferOutputs

checkUnlockScript

  • checkUnlockScript(unlockScript: Buffer): void

checkUsers

checkWorldId

  • checkWorldId(worldId: number): void

convertU16toHex

  • convertU16toHex(id: number): string

decode

  • decode(str: string, prefix: string, LIMIT?: undefined | number): object
  • Parameters

    • str: string
    • prefix: string
    • Optional LIMIT: undefined | number

    Returns object

    • prefix: string
    • words: number[]

encode

  • encode(prefix: any, words: any, LIMIT?: any): any
  • Parameters

    • prefix: any
    • words: any
    • Optional LIMIT: any

    Returns any

fromWords

  • fromWords(words: any): number[]

Const generatePrivateKey

  • generatePrivateKey(): string
  • Generates a private key.

    Returns string

    32 byte hexadecimal string of private key

Const getAccountIdFromPrivate

  • getAccountIdFromPrivate(priv: string): string
  • Gets account id from private key.

    Parameters

    • priv: string

      32 byte hexadecimal string of private key

    Returns string

    20 byte hexadecimal string of account id

Const getAccountIdFromPublic

  • getAccountIdFromPublic(publicKey: string): string
  • Gets account id from the given public key.

    Parameters

    • publicKey: string

      64 byte hexadecimal string of uncompressed public key

    Returns string

    20 byte hexadecimal string of account id

getActionFromJSON

  • getActionFromJSON(json: any): Action

Const getPublicFromPrivate

  • getPublicFromPrivate(priv: string): string
  • Gets public key from private key.

    Parameters

    • priv: string

      32 byte hexadecimal string of private key

    Returns string

    64 byte hexadecimal string of public key

Const getTransactionFromJSON

isIpAddressString

  • isIpAddressString(value: any): boolean

isKeyStore

  • isKeyStore(value: any): boolean

isNonNegativeInterger

  • isNonNegativeInterger(value: any): boolean

isPortNumber

  • isPortNumber(value: any): boolean

isShardIdValue

  • isShardIdValue(value: any): boolean

isWorldIdValue

  • isWorldIdValue(value: any): boolean

Const recoverEcdsa

  • Gets public key from the message and signature.

    Parameters

    • message: string

      arbitrary length string

    • signature: EcdsaSignature

      r, s, v of ECDSA signature

    Returns string

    64 byte hexadecimal string public key

Const ripemd160

  • ripemd160(data: Buffer | string): string
  • Gets data's 160 bit RIPEMD hash.

    Parameters

    • data: Buffer | string

      buffer or hexadecimal string

    Returns string

    20 byte hexadecimal string

Const signEcdsa

  • Gets signature for message from private key.

    Parameters

    • message: string

      arbitrary length string

    • priv: string

      32 byte hexadecimal string of private key

    Returns EcdsaSignature

    r, s, v of ECDSA signature

Const toHex

  • toHex(buffer: Buffer): string
  • Converts buffer to hexadecimal string.

    Parameters

    • buffer: Buffer

      arbritrary length of data

    Returns string

    hexadecimal string

Const toHexByte

  • toHexByte(byte: number): string
  • Parameters

    • byte: number

    Returns string

toWords

  • toWords(bytes: any): number[]

Const verifyEcdsa

  • verifyEcdsa(message: string, signature: EcdsaSignature, pub: string): boolean
  • Checks if the signature from signEcdsa is correct.

    Parameters

    • message: string

      arbitrary length string

    • signature: EcdsaSignature

      r, s, v of ECDSA signature

    • pub: string

      64 byte hexadecimal string of public key

    Returns boolean

    if signature is valid, true. Else false.

Generated using TypeDoc