Class: SingleNodeClient
Client for API communication.
Implements
Table of contents
Constructors
Methods
- health
- routes
- info
- tips
- block
- blockMetadata
- blockRaw
- blockSubmit
- blockSubmitRaw
- transactionIncludedBlock
- transactionIncludedBlockRaw
- output
- outputMetadata
- outputRaw
- milestoneByIndex
- milestoneByIndexRaw
- milestoneUtxoChangesByIndex
- milestoneById
- milestoneByIdRaw
- milestoneUtxoChangesById
- treasury
- receipts
- peers
- peerAdd
- peerDelete
- peer
- protocolInfo
- pluginFetch
Constructors
constructor
• new SingleNodeClient(endpoint
, options?
)
Create a new instance of client.
Parameters
Name | Type | Description |
---|---|---|
endpoint | string | The endpoint. |
options? | SingleNodeClientOptions | Options 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
routes
▸ routes(): Promise
<IRoutesResponse
>
Get the routes the node exposes.
Returns
Promise
<IRoutesResponse
>
The routes.
Implementation of
info
▸ info(): Promise
<INodeInfo
>
Get the info about the node.
Returns
Promise
<INodeInfo
>
The node information.
Implementation of
tips
▸ tips(): Promise
<ITipsResponse
>
Get the tips from the node.
Returns
Promise
<ITipsResponse
>
The tips.
Implementation of
block
▸ block(blockId
): Promise
<IBlock
>
Get the block data by id.
Parameters
Name | Type | Description |
---|---|---|
blockId | string | The block to get the data for. |
Returns
Promise
<IBlock
>
The block data.
Implementation of
blockMetadata
▸ blockMetadata(blockId
): Promise
<IBlockMetadata
>
Get the block metadata by id.
Parameters
Name | Type | Description |
---|---|---|
blockId | string | The block to get the metadata for. |
Returns
Promise
<IBlockMetadata
>
The block metadata.
Implementation of
blockRaw
▸ blockRaw(blockId
): Promise
<Uint8Array
>
Get the block raw data by id.
Parameters
Name | Type | Description |
---|---|---|
blockId | string | The block to get the data for. |
Returns
Promise
<Uint8Array
>
The block raw data.
Implementation of
blockSubmit
▸ blockSubmit(blockPartial
): Promise
<string
>
Submit block.
Parameters
Name | Type | Description |
---|---|---|
blockPartial | Object | The block to submit (possibly contains only partial block data). |
Returns
Promise
<string
>
The blockId.
Implementation of
blockSubmitRaw
▸ blockSubmitRaw(block
): Promise
<string
>
Submit block in raw format.
Parameters
Name | Type | Description |
---|---|---|
block | Uint8Array | The block to submit. |
Returns
Promise
<string
>
The blockId.
Implementation of
transactionIncludedBlock
▸ transactionIncludedBlock(transactionId
): Promise
<IBlock
>
Get the block that was included in the ledger for a transaction.
Parameters
Name | Type | Description |
---|---|---|
transactionId | string | The 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
Name | Type | Description |
---|---|---|
transactionId | string | The 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
Name | Type | Description |
---|---|---|
outputId | string | The id of the output to get. |
Returns
Promise
<IOutputResponse
>
The output details.
Implementation of
outputMetadata
▸ outputMetadata(outputId
): Promise
<IOutputMetadataResponse
>
Get an outputs metadata by its identifier.
Parameters
Name | Type | Description |
---|---|---|
outputId | string | The id of the output to get the metadata for. |
Returns
Promise
<IOutputMetadataResponse
>
The output metadata.
Implementation of
outputRaw
▸ outputRaw(outputId
): Promise
<Uint8Array
>
Get an outputs raw data.
Parameters
Name | Type | Description |
---|---|---|
outputId | string | The id of the output to get the raw data for. |
Returns
Promise
<Uint8Array
>
The output raw bytes.
Implementation of
milestoneByIndex
▸ milestoneByIndex(index
): Promise
<IMilestonePayload
>
Get the requested milestone.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the milestone to look up. |
Returns
Promise
<IMilestonePayload
>
The milestone payload.
Implementation of
milestoneByIndexRaw
▸ milestoneByIndexRaw(index
): Promise
<Uint8Array
>
Get the requested milestone raw.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the milestone to look up. |
Returns
Promise
<Uint8Array
>
The milestone payload raw.
Implementation of
milestoneUtxoChangesByIndex
▸ milestoneUtxoChangesByIndex(index
): Promise
<IMilestoneUtxoChangesResponse
>
Get the requested milestone utxo changes.
Parameters
Name | Type | Description |
---|---|---|
index | number | The 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
Name | Type | Description |
---|---|---|
milestoneId | string | The id of the milestone to look up. |
Returns
Promise
<IMilestonePayload
>
The milestone payload.
Implementation of
milestoneByIdRaw
▸ milestoneByIdRaw(milestoneId
): Promise
<Uint8Array
>
Get the requested milestone raw.
Parameters
Name | Type | Description |
---|---|---|
milestoneId | string | The id of the milestone to look up. |
Returns
Promise
<Uint8Array
>
The milestone payload raw.
Implementation of
milestoneUtxoChangesById
▸ milestoneUtxoChangesById(milestoneId
): Promise
<IMilestoneUtxoChangesResponse
>
Get the requested milestone utxo changes.
Parameters
Name | Type | Description |
---|---|---|
milestoneId | string | The 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
receipts
▸ receipts(migratedAt?
): Promise
<IReceiptsResponse
>
Get all the stored receipts or those for a given migrated at index.
Parameters
Name | Type | Description |
---|---|---|
migratedAt? | number | The index the receipts were migrated at, if not supplied returns all stored receipts. |
Returns
Promise
<IReceiptsResponse
>
The stored receipts.
Implementation of
peers
▸ peers(): Promise
<IPeer
[]>
Get the list of peers.
Returns
Promise
<IPeer
[]>
The list of peers.
Implementation of
peerAdd
▸ peerAdd(multiAddress
, alias?
): Promise
<IPeer
>
Add a new peer.
Parameters
Name | Type | Description |
---|---|---|
multiAddress | string | The address of the peer to add. |
alias? | string | An optional alias for the peer. |
Returns
Promise
<IPeer
>
The details for the created peer.
Implementation of
peerDelete
▸ peerDelete(peerId
): Promise
<void
>
Delete a peer.
Parameters
Name | Type | Description |
---|---|---|
peerId | string | The peer to delete. |
Returns
Promise
<void
>
Nothing.
Implementation of
peer
▸ peer(peerId
): Promise
<IPeer
>
Get a peer.
Parameters
Name | Type | Description |
---|---|---|
peerId | string | The peer to delete. |
Returns
Promise
<IPeer
>
The details for the created peer.
Implementation of
protocolInfo
▸ protocolInfo(): Promise
<{}>
Get the protocol info from the node.
Returns
Promise
<{}>
The protocol info.
Implementation of
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
Name | Type | Description |
---|---|---|
basePluginPath | string | The base path for the plugin eg indexer/v1/ . |
method | "get" | "post" | "delete" | The http method. |
methodPath | string | The path for the plugin request. |
queryParams? | string [] | Additional query params for the request. |
request? | T | The request object. |
Returns
Promise
<S
>
The response object.