Skip to main content

Class: SingleNodeClient

Client for API communication.

Implements

Table of contents

Constructors

Methods

Constructors

constructor

new SingleNodeClient(endpoint, options?)

Create a new instance of client.

Parameters

NameTypeDescription
endpointstringThe endpoint.
options?SingleNodeClientOptionsOptions for the client.

Methods

health

health(): Promise<boolean>

Get the health of the node.

Returns

Promise<boolean>

True if the node is healthy.

Implementation of

IClient.health


routes

routes(): Promise<IRoutesResponse>

Get the routes the node exposes.

Returns

Promise<IRoutesResponse>

The routes.

Implementation of

IClient.routes


info

info(): Promise<INodeInfo>

Get the info about the node.

Returns

Promise<INodeInfo>

The node information.

Implementation of

IClient.info


tips

tips(): Promise<ITipsResponse>

Get the tips from the node.

Returns

Promise<ITipsResponse>

The tips.

Implementation of

IClient.tips


block

block(blockId): Promise<IBlock>

Get the block data by id.

Parameters

NameTypeDescription
blockIdstringThe block to get the data for.

Returns

Promise<IBlock>

The block data.

Implementation of

IClient.block


blockMetadata

blockMetadata(blockId): Promise<IBlockMetadata>

Get the block metadata by id.

Parameters

NameTypeDescription
blockIdstringThe block to get the metadata for.

Returns

Promise<IBlockMetadata>

The block metadata.

Implementation of

IClient.blockMetadata


blockRaw

blockRaw(blockId): Promise<Uint8Array>

Get the block raw data by id.

Parameters

NameTypeDescription
blockIdstringThe block to get the data for.

Returns

Promise<Uint8Array>

The block raw data.

Implementation of

IClient.blockRaw


blockSubmit

blockSubmit(blockPartial): Promise<string>

Submit block.

Parameters

NameTypeDescription
blockPartialObjectThe block to submit (possibly contains only partial block data).

Returns

Promise<string>

The blockId.

Implementation of

IClient.blockSubmit


blockSubmitRaw

blockSubmitRaw(block): Promise<string>

Submit block in raw format.

Parameters

NameTypeDescription
blockUint8ArrayThe block to submit.

Returns

Promise<string>

The blockId.

Implementation of

IClient.blockSubmitRaw


transactionIncludedBlock

transactionIncludedBlock(transactionId): Promise<IBlock>

Get the block that was included in the ledger for a transaction.

Parameters

NameTypeDescription
transactionIdstringThe id of the transaction to get the included block for.

Returns

Promise<IBlock>

The block.

Implementation of

IClient.transactionIncludedBlock


transactionIncludedBlockRaw

transactionIncludedBlockRaw(transactionId): Promise<Uint8Array>

Get raw block that was included in the ledger for a transaction.

Parameters

NameTypeDescription
transactionIdstringThe id of the transaction to get the included block for.

Returns

Promise<Uint8Array>

The block.

Implementation of

IClient.transactionIncludedBlockRaw


output

output(outputId): Promise<IOutputResponse>

Get an output by its identifier.

Parameters

NameTypeDescription
outputIdstringThe id of the output to get.

Returns

Promise<IOutputResponse>

The output details.

Implementation of

IClient.output


outputMetadata

outputMetadata(outputId): Promise<IOutputMetadataResponse>

Get an outputs metadata by its identifier.

Parameters

NameTypeDescription
outputIdstringThe id of the output to get the metadata for.

Returns

Promise<IOutputMetadataResponse>

The output metadata.

Implementation of

IClient.outputMetadata


outputRaw

outputRaw(outputId): Promise<Uint8Array>

Get an outputs raw data.

Parameters

NameTypeDescription
outputIdstringThe id of the output to get the raw data for.

Returns

Promise<Uint8Array>

The output raw bytes.

Implementation of

IClient.outputRaw


milestoneByIndex

milestoneByIndex(index): Promise<IMilestonePayload>

Get the requested milestone.

Parameters

NameTypeDescription
indexnumberThe index of the milestone to look up.

Returns

Promise<IMilestonePayload>

The milestone payload.

Implementation of

IClient.milestoneByIndex


milestoneByIndexRaw

milestoneByIndexRaw(index): Promise<Uint8Array>

Get the requested milestone raw.

Parameters

NameTypeDescription
indexnumberThe index of the milestone to look up.

Returns

Promise<Uint8Array>

The milestone payload raw.

Implementation of

IClient.milestoneByIndexRaw


milestoneUtxoChangesByIndex

milestoneUtxoChangesByIndex(index): Promise<IMilestoneUtxoChangesResponse>

Get the requested milestone utxo changes.

Parameters

NameTypeDescription
indexnumberThe index of the milestone to request the changes for.

Returns

Promise<IMilestoneUtxoChangesResponse>

The milestone utxo changes details.

Implementation of

IClient.milestoneUtxoChangesByIndex


milestoneById

milestoneById(milestoneId): Promise<IMilestonePayload>

Get the requested milestone.

Parameters

NameTypeDescription
milestoneIdstringThe id of the milestone to look up.

Returns

Promise<IMilestonePayload>

The milestone payload.

Implementation of

IClient.milestoneById


milestoneByIdRaw

milestoneByIdRaw(milestoneId): Promise<Uint8Array>

Get the requested milestone raw.

Parameters

NameTypeDescription
milestoneIdstringThe id of the milestone to look up.

Returns

Promise<Uint8Array>

The milestone payload raw.

Implementation of

IClient.milestoneByIdRaw


milestoneUtxoChangesById

milestoneUtxoChangesById(milestoneId): Promise<IMilestoneUtxoChangesResponse>

Get the requested milestone utxo changes.

Parameters

NameTypeDescription
milestoneIdstringThe id of the milestone to request the changes for.

Returns

Promise<IMilestoneUtxoChangesResponse>

The milestone utxo changes details.

Implementation of

IClient.milestoneUtxoChangesById


treasury

treasury(): Promise<ITreasury>

Get the current treasury output.

Returns

Promise<ITreasury>

The details for the treasury.

Implementation of

IClient.treasury


receipts

receipts(migratedAt?): Promise<IReceiptsResponse>

Get all the stored receipts or those for a given migrated at index.

Parameters

NameTypeDescription
migratedAt?numberThe index the receipts were migrated at, if not supplied returns all stored receipts.

Returns

Promise<IReceiptsResponse>

The stored receipts.

Implementation of

IClient.receipts


peers

peers(): Promise<IPeer[]>

Get the list of peers.

Returns

Promise<IPeer[]>

The list of peers.

Implementation of

IClient.peers


peerAdd

peerAdd(multiAddress, alias?): Promise<IPeer>

Add a new peer.

Parameters

NameTypeDescription
multiAddressstringThe address of the peer to add.
alias?stringAn optional alias for the peer.

Returns

Promise<IPeer>

The details for the created peer.

Implementation of

IClient.peerAdd


peerDelete

peerDelete(peerId): Promise<void>

Delete a peer.

Parameters

NameTypeDescription
peerIdstringThe peer to delete.

Returns

Promise<void>

Nothing.

Implementation of

IClient.peerDelete


peer

peer(peerId): Promise<IPeer>

Get a peer.

Parameters

NameTypeDescription
peerIdstringThe peer to delete.

Returns

Promise<IPeer>

The details for the created peer.

Implementation of

IClient.peer


protocolInfo

protocolInfo(): Promise<{}>

Get the protocol info from the node.

Returns

Promise<{}>

The protocol info.

Implementation of

IClient.protocolInfo


pluginFetch

pluginFetch<T, S>(basePluginPath, method, methodPath, queryParams?, request?): Promise<S>

Extension method which provides request methods for plugins.

Type parameters

Name
T
S

Parameters

NameTypeDescription
basePluginPathstringThe base path for the plugin eg indexer/v1/ .
method"get" | "post" | "delete"The http method.
methodPathstringThe path for the plugin request.
queryParams?string[]Additional query params for the request.
request?TThe request object.

Returns

Promise<S>

The response object.

Implementation of

IClient.pluginFetch