API Documentation

Crypto\Blocks\BlockFactory

fromHex()

public static fromHex(hex: string)

Generate Block object from HEX.

Parameters

Type

Name

Required

Description

string

hex

Yes

Block content

Return Value

IBlock

fromBytes()

public static fromBytes(buffer: Buffer)

Generate Block object from a Buffer.

Parameters

Type

Name

Required

Description

Buffer

buffer

Yes

Block content

Return Value

IBlock

fromJson()

public static fromJson(json: IBlockJson)

Generate Block object from JSON.

Parameters

Type

Name

Required

Description

IBlockJson

json

Yes

Block content

Return Value

IBlock

fromData()

public static fromData(data: IBlockData, options: { deserializeTransactionsUnchecked?: boolean } = {})

Generate Block object from Block data.

Parameters

Type

Name

Required

Description

IBlockData

data

Yes

Block content

object

options

Yes

Options used for parsing block data

Return Value

IBlock

Crypto\Blocks\Serializer

size()

public static size(block: IBlock)

Get size of Block.

Parameters

Type

Name

Required

Description

IBlock

block

Yes

Block object

Return Value

number

serializeWithTransactions()

public static serializeWithTransactions(block: IBlockData)

Serialize Block with Transactions.

Parameters

Type

Name

Required

Description

IBlockData

block

Yes

Block object

Return Value

Buffer

serialize()

public static serialize(block: IBlockData, includeSignature: boolean = true)

Serialize Block without Transactions.

Parameters

Type

Name

Required

Description

IBlockData

block

Yes

Block object

boolean

includeSignature

Yes

Whether to include signature in serialization

Return Value

Buffer

Crypto\Crypto\HashAlgorithms

ripemd160()

public static ripemd160(buffer: Buffer | string)

Hash with RIPEMD-160.

Parameters

Type

Name

Required

Description

Buffer, string

buffer

Yes

String or Buffer to generate hash for

Return Value

Buffer

sha1()

public static sha1(buffer: Buffer | string)

Hash with SHA-1.

Parameters

Type

Name

Required

Description

Buffer, string

buffer

Yes

String or Buffer to generate hash for

Return Value

Buffer

sha256()

public static sha256(buffer: Buffer | string | Buffer[])

Hash with SHA-256.

Parameters

Type

Name

Required

Description

Buffer, string

buffer

Yes

String or Buffer to generate hash for

Return Value

Buffer

hash160()

public static hash160(buffer: Buffer | string)

Hash with Hash160.

Parameters

Type

Name

Required

Description

Buffer, string

buffer

Yes

String or Buffer to generate hash for

Return Value

Buffer

hash256()

public static hash256(buffer: Buffer | string)

Hash with Hash256.

Parameters

Type

Name

Required

Description

Buffer, string

buffer

Yes

String or Buffer to generate hash for

Return Value

Buffer

Crypto\Crypto\Hash

signECDSA()

public static signECDSA(hash: Buffer, keys: IKeyPair)

Sign hash with ECDSA.

Parameters

Type

Name

Required

Description

Buffer

hash

Yes

Hash to sign

IKeyPair

keys

Yes

Keys to sign hash with

Return Value

string

verifyECDSA()

public static verifyECDSA(hash: Buffer, signature: Buffer | string, publicKey: Buffer | string)

Verify ECDSA signature.

Parameters

Type

Name

Required

Description

Buffer

hash

Yes

Hash to verify

Buffer, string

signature

Yes

Signature of hash

Buffer, string

publicKey

Yes

Public key of wallet which signed the hash

Return Value

boolean

signSchnorr()

public static signSchnorr(hash: Buffer, keys: IKeyPair)

Sign hash with Schnorr.

Parameters

Type

Name

Required

Description

Buffer

hash

Yes

Hash to sign

IKeyPair

keys

Yes

Keys to sign hash with

Return Value

string

verifySchnorr()

public static verifySchnorr(hash: Buffer, signature: Buffer | string, publicKey: Buffer | string)

Verify Schnorr signature.

Parameters

Type

Name

Required

Description

Buffer

hash

Yes

Hash to verify

Buffer, string

signature

Yes

Signature of hash

Buffer, string

publicKey

Yes

Public key of wallet which signed the hash

Return Value

boolean

Crypto\Crypto\HDWallet

fromMnemonic()

public static fromMnemonic(mnemonic: string, passphrase?: string)

Generate BIP32 Wallet from mnemonic.

Parameters

Type

Name

Required

Description

string

mnemonic

Yes

INSERT_DESCRIPTION

string

passphrase

No

INSERT_DESCRIPTION

Return Value

BIP32Interface

fromKeys()

public static fromKeys(keys: IKeyPair, chainCode: Buffer)

Generate BIP32 Wallet from KeyPair.

Parameters

Type

Name

Required

Description

IKeyPair

keys

Yes

INSERT_DESCRIPTION

Buffer

chainCode

Yes

INSERT_DESCRIPTION

Return Value

BIP32Interface

getKeys()

public static getKeys(node: BIP32Interface)

Get keys for BIP32 Wallet.

Parameters

Type

Name

Required

Description

BIP32Interface

node

Yes

BIP32 Wallet to get keys for

Return Value

IKeyPair

deriveSlip44()

public static deriveSlip44(root: BIP32Interface, hardened: boolean = true)

Determine Slip44 for BIP32 Wallet.

Parameters

Type

Name

Required

Description

BIP32Interface

root

Yes

BIP32 Wallet to determine Slip44 for

boolean

hardened

Yes

INSERT_DESCRIPTION

Return Value

BIP32Interface

deriveNetwork()

public static deriveNetwork(root: BIP32Interface)

Determine Network for BIP32 Wallet.

Parameters

Type

Name

Required

Description

BIP32Interface

root

Yes

BIP32 Wallet to determine network for

Return Value

BIP32Interface

Crypto\Crypto\Message

sign()

public static sign(message: string, passphrase: string)

Sign a message using the given passphrase.

Parameters

Type

Name

Required

Description

string

message

Yes

Message

string

passphrase

Yes

Passphrase

Return Value

IMessage

signWithWif()

public static signWithWif(message: string, wif: string, network?: INetwork)

Sign a message using the given WIF string.

Parameters

Type

Name

Required

Description

string

message

Yes

Message

string

wif

Yes

Network WIF

INetwork

network

No

Network

Return Value

IMessage

verify()

public static verify({ message, publicKey, signature }: IMessage)

Verify the message contents

Parameters

Type

Name

Required

Description

IMessage

object

Yes

Message

Return Value

boolean

Crypto\Crypto\Slots

getTime()

public static getTime(time?: number)

Get the time diff between now and network start.

Parameters

Type

Name

Required

Description

number

time

No

Network start time

Return Value

number

getTimeInMsUntilNextSlot()

public static getTimeInMsUntilNextSlot()

Get the time (in milliseconds) until the start of the next slot.

Return Value

number

getSlotNumber()

public static getSlotNumber(epoch?: number)

Get the slot number.

Parameters

Type

Name

Required

Description

number

epoch

No

Epoch time

Return Value

number

getSlotTime()

public static getSlotTime(slot: number)

Get the slot time.

Parameters

Type

Name

Required

Description

number

slot

Yes

Slot

Return Value

number

getNextSlot()

public static getNextSlot()

Get the next slot.

Return Value

number

isForgingAllowed()

public static isForgingAllowed(epoch?: number)

Verify is forging is allowed.

Parameters

Type

Name

Required

Description

number

epoch

No

Epoch time

Return Value

boolean

Crypto\Identities\Address

fromPassphrase()

public static fromPassphrase(passphrase: string, networkVersion?: number)

Derive the address from the given passphrase.

Parameters

Type

Name

Required

Description

string

passphrase

Yes

Passphrase

number

networkVersion

No

Version of the network

Return Value

string

fromPublicKey()

public static fromPublicKey(publicKey: string, networkVersion?: number)

Derive a (multisig) address from a multi signature asset.

Parameters

Type

Name

Required

Description

string

publicKey

Yes

Public key

number

networkVersion

No

Version of the network

Return Value

string

fromWIF()

public static fromWIF(wif: string, network?: NetworkType)

Derive the address from a WIF string.

Parameters

Type

Name

Required

Description

string

wif

Yes

WIF

NetworkType

network

No

Network to generate address for

Return Value

string

fromMultiSignatureAsset()

public static fromMultiSignatureAsset(asset: IMultiSignatureAsset, networkVersion?: number)

Derive the address from the given multi signature asset.

Parameters

Type

Name

Required

Description

IMultiSignatureAsset

asset

Yes

Address to validate

number

networkVersion

No

Version of the network

Return Value

string

fromPrivateKey()

public static fromPrivateKey(privateKey, networkVersion?: number)

Derive the address from the given private key.

Parameters

Type

Name

Required

Description

any

privateKey

Yes

Private key to derive address for

number

networkVersion

No

Version of the network

Return Value

string

fromBuffer()

public static fromBuffer(buffer: Buffer)

Derive the address from a Buffer.

Parameters

Type

Name

Required

Description

Buffer

buffer

Yes

Buffer to derive address from

Return Value

string

toBuffer()

public static toBuffer(address: string)

Convert address to a Buffer.

Parameters

Type

Name

Required

Description

string

address

Yes

Address to convert to buffer

Return Value

{ addressBuffer: Buffer; addressError?: string }

validate()

public static validate(address: string, networkVersion?: number)

Validate the given address.

Parameters

Type

Name

Required

Description

string

address

Yes

Address to validate

number

networkVersion

No

Version of the network

Return Value

boolean

Crypto\Identities\Keys

fromPassphrase()

public static fromPassphrase(passphrase: string, compressed: boolean = true)

Derive the keys from the given passphrase.

Parameters

Type

Name

Required

Description

string

passphrase

Yes

Passphrase

boolean

compressed

Yes

Compression flag

Return Value

IKeyPair

fromPrivateKey()

public static fromPrivateKey(privateKey: Buffer | string, compressed: boolean = true)

Derive the keys from the given private key.

Parameters

Type

Name

Required

Description

Buffer, string

privateKey

Yes

Private Key to derive keys from

boolean

compressed

Yes

Compression flag

Return Value

IKeyPair

fromWIF()

public static fromWIF(wifKey: string, network?: INetwork)

Derive the keys from the given WIF.

Parameters

Type

Name

Required

Description

string

wifKey

Yes

Private key

INetwork

network

No

Network

Return Value

IKeyPair

Crypto\Identities\PrivateKey

fromPassphrase()

public static fromPassphrase(passphrase: string)

Derive the private key for the given passphrase.

Parameters

Type

Name

Required

Description

string

passphrase

Yes

Passphrase

Return Value

string

fromWIF()

public static fromWIF(wif: string, network?: NetworkType)

Create a private key instance from a hex string.

Parameters

Type

Name

Required

Description

string

wif

Yes

Network WIF

NetworkType

network

No

Network

Return Value

string

Crypto\Identities\PublicKey

fromPassphrase()

public static fromPassphrase(passphrase: string)

Derive the public key from the given passphrase.

Parameters

Type

Name

Required

Description

string

passphrase

Yes

Passphrase

Return Value

string

fromWIF()

public static fromWIF(wif: string, network?: NetworkType)

Derive the public key from the given WIF.

Parameters

Type

Name

Required

Description

string

wif

Yes

WIF to derive public key from

NetworkType

network

No

Network

Return Value

string

fromMultiSignatureAsset()

public static fromMultiSignatureAsset(asset: IMultiSignatureAsset)

Derive the public key from the given multi signature asset.

Parameters

Type

Name

Required

Description

IMultiSignatureAsset

asset

Yes

Asset

Return Value

string

validate()

public static validate(publicKey: string, networkVersion?: number)

Validate the given public key.

Parameters

Type

Name

Required

Description

string

publicKey

Yes

Public key

number

networkVersion

No

Network version

Return Value

boolean

Crypto\Identities\WIF

fromPassphrase()

public static fromPassphrase(passphrase: string, network?: INetwork)

Derive the WIF from the given passphrase.

Parameters

Type

Name

Required

Description

string

passphrase

Yes

Passphrase to derive WIF from

INetwork

network

No

Network wif

Return Value

string

fromKeys()

public static fromKeys(keys: IKeyPair, network?: INetwork)

Derive the WIF from the given keys.

Parameters

Type

Name

Required

Description

IKeyPair

keys

Yes

Keys

INetwork

network

No

Network

Return Value

string

Crypto\Managers\ConfigManager

setConfig()

public setConfig(config: INetworkConfig)

Set the configuration.

Parameters

Type

Name

Required

Description

INetworkConfig

config

Yes

Network configuration object

Return Value

void

setFromPreset()

public setFromPreset(network: NetworkName)

Set the configuration from given presets.

Parameters

Type

Name

Required

Description

NetworkName

network

Yes

Preset

Return Value

void

getPreset()

public getPreset(network: NetworkName)

Get configuration preset.

Parameters

Type

Name

Required

Description

NetworkName

network

Yes

Preset

Return Value

INetworkConfig

all()

public all()

Get all configs.

Return Value

INetworkConfig

set()

public set<T = any>(key: string, value: T)

Set a value for the specified network config key.

Parameters

Type

Name

Required

Description

string

key

Yes

Key to set

T

value

Yes

Value to set

Return Value

void

get()

public get<T = any>(key: string)

Get key.

Parameters

Type

Name

Required

Description

string

key

Yes

Key to get

Return Value

T

setHeight()

public setHeight(value: number)

Set network height.

Parameters

Type

Name

Required

Description

number

value

Yes

Network height

Return Value

void

getHeight()

public getHeight()

Get network height.

Return Value

number

isNewMilestone()

public isNewMilestone(height?: number)

Verify if current height contains a milestone.

Parameters

Type

Name

Required

Description

number

height

No

Height to check for milestone

Return Value

boolean

getMilestone()

public getMilestone(height?: number)

Get milestone.

Parameters

Type

Name

Required

Description

number

height

No

Network height

Return Value

{ [key: string]: any }

getMilestones()

public getMilestones()

Get all milestones.

Return Value

any

Crypto\Managers\NetworkManager

all()

public static all()

Get settings for all networks.

Return Value

Record<NetworkName, INetworkConfig>

findByName()

public static findByName(name: NetworkName)

Get settings for a selected network, default network is devnet.

Parameters

Type

Name

Required

Description

NetworkName

name

Yes

Network name

Return Value

INetworkConfig

Crypto\Transactions\Deserializer

deserialize()

public static deserialize(serialized: string | Buffer, options: IDeserializeOptions = {})

Deserialize Transaction into object.

Parameters

Type

Name

Required

Description

string, Buffer

serialized

Yes

Serialized transaction

IDeserializeOptions

options

Yes

Options for deserializing

Return Value

ITransaction

applyV1Compatibility()

public static applyV1Compatibility(transaction: ITransactionData)

Modify transaction to be v1 compatible.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction object

Return Value

void

Crypto\Transactions\TransactionFactory

fromHex()

public static fromHex(hex: string)

Create Transaction object from HEX.

Parameters

Type

Name

Required

Description

string

hex

Yes

HEX of transaction

Return Value

ITransaction

fromBytes()

public static fromBytes(buffer: Buffer, strict: boolean = true)

Create Transaction object from Buffer.

Parameters

Type

Name

Required

Description

Buffer

buffer

Yes

Transaction buffer

boolean

strict

Yes

Strict creation from buffer

Return Value

ITransaction

fromBytesUnsafe()

public static fromBytesUnsafe(buffer: Buffer, id?: string)

Create Transaction object from Buffer (unsafe).

NOTE: Only use this internally when it is safe to assume the buffer has already been verified.

Parameters

Type

Name

Required

Description

Buffer

buffer

Yes

Transaction buffer

string

id

No

ID override

Return Value

ITransaction

fromJson()

public static fromJson(json: ITransactionJson)

Create Transaction object from JSON.

Parameters

Type

Name

Required

Description

ITransactionJson

json

Yes

Transaction JSON object

Return Value

ITransaction

fromData()

public static fromData(data: ITransactionData, strict: boolean = true)

Create Transaction object from Transaction data.

Parameters

Type

Name

Required

Description

ITransactionData

data

Yes

Transaction object

boolean

strict

Yes

Strict conversion

Return Value

ITransaction

Crypto\Transactions\Serializer

getBytes()

public static getBytes(transaction: ITransactionData, options: ISerializeOptions = {})

Convert the transaction to its byte representation.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction

ISerializeOptions

options

Yes

Options

Return Value

Buffer

serialize()

public static serialize(transaction: ITransaction, options: ISerializeOptions = {})

Perform AIP11 compliant serialization.

Parameters

Type

Name

Required

Description

ITransaction

transaction

Yes

Transaction

ISerializeOptions

options

Yes

Options

Return Value

Buffer

Crypto\Transactions\Signer

sign()

public static sign(transaction: ITransactionData, keys: IKeyPair, options?: ISerializeOptions)

Sign the given transaction with the provided keys.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction

IKeyPair

keys

Yes

Keys

ISerializeOptions

options

No

Options

Return Value

string

secondSign()

public static secondSign(transaction: ITransactionData, keys: IKeyPair)

Second sign the given transaction with the provided keys.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction

IKeyPair

keys

Yes

Keys

Return Value

string

multiSign()

public static multiSign(transaction: ITransactionData, keys: IKeyPair, index: number = -1)

Multi sign the given transaction with the provided keys.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction

IKeyPair

keys

Yes

Keys

number

index

Yes

Index

Return Value

string

Crypto\Transactions\Utils

toBytes()

public static toBytes(data: ITransactionData)

Convert Transaction object to Buffer.

Parameters

Type

Name

Required

Description

ITransactionData

data

Yes

Transaction object

Return Value

Buffer

toHash()

public static toHash(transaction: ITransactionData, options?: ISerializeOptions)

Convert Transaction object to Hash.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction object

ISerializeOptions

options

No

Serialization options for generating hash

Return Value

Buffer

getId()

public static getId(transaction: ITransactionData, options: ISerializeOptions = {})

Get Transaction ID of Transaction object.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction object

ISerializeOptions

options

Yes

Serialization options for generating hash

Return Value

string

Crypto\Transactions\Verifier

verify()

public static verify(data: ITransactionData)

Verify transaction.

Parameters

Type

Name

Required

Description

ITransactionData

data

Yes

Transaction object

Return Value

boolean

verifySecondSignature()

public static verifySecondSignature(transaction: ITransactionData, publicKey: string)

Verify second signature.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction object

string

publicKey

Yes

Public key

Return Value

boolean

verifySignatures()

public static verifySignatures(transaction: ITransactionData, multiSignature: IMultiSignatureAsset)

Verify the signatures of a Transaction object.

Parameters

Type

Name

Required

Description

ITransactionData

transaction

Yes

Transaction object

IMultiSignatureAsset

multiSignature

Yes

Asset for Multi-Signature wallets/transactions

Return Value

boolean

verifyHash()

public static verifyHash(data: ITransactionData)

Verify transaction hash.

Parameters

Type

Name

Required

Description

ITransactionData

data

Yes

Transaction

Return Value

boolean

verifySchema()

public static verifySchema(data: ITransactionData, strict: boolean = true)

Verify transaction schema.

Parameters

Type

Name

Required

Description

ITransactionData

data

Yes

Transaction

boolean

strict

Yes

Strict flag

Return Value

ISchemaValidationResult

Crypto\Transactions\Builders\BuilderFactory

transfer()

public static transfer()

Initiate a Transfer transaction type.

Return Value

TransferBuilder

secondSignature()