Skip to main content

Class: ChronikClientNode

Client to access an in-node Chronik instance. Plain object, without any connections.

Constructors

constructor

new ChronikClientNode(urls): ChronikClientNode

Create a new client. This just creates an object, without any connections.

Parameters

NameTypeDescription
urlsstring[]Array of valid urls. A valid url comes with schema and without a trailing slash. e.g. '['https://chronik.be.cash/xec2', 'https://chronik-native.fabien.cash'] The approach of accepting an array of urls as input is to ensure redundancy if the first url encounters downtime.

Returns

ChronikClientNode

Throws

throws error on invalid constructor inputs

Defined in

src/ChronikClientNode.ts:31

Methods

address

address(address): ScriptEndpointInNode

Create object that allows fetching script history or UTXOs by p2pkh or p2sh address

Parameters

NameType
addressstring

Returns

ScriptEndpointInNode

Defined in

src/ChronikClientNode.ts:171


block

block(hashOrHeight): Promise<Block_InNode>

Fetch the block given hash or height.

Parameters

NameType
hashOrHeightstring | number

Returns

Promise<Block_InNode>

Defined in

src/ChronikClientNode.ts:98


blockTxs

blockTxs(hashOrHeight, page?, pageSize?): Promise<TxHistoryPage_InNode>

Fetch the tx history of a block given hash or height.

Parameters

NameTypeDefault value
hashOrHeightstring | numberundefined
pagenumber0
pageSizenumber25

Returns

Promise<TxHistoryPage_InNode>

Defined in

src/ChronikClientNode.ts:105


blockchainInfo

blockchainInfo(): Promise<BlockchainInfo>

Fetch current info of the blockchain, such as tip hash and height.

Returns

Promise<BlockchainInfo>

Defined in

src/ChronikClientNode.ts:84


blocks

blocks(startHeight, endHeight): Promise<BlockInfo_InNode[]>

Fetch block info of a range of blocks. startHeight and endHeight are inclusive ranges.

Parameters

NameType
startHeightnumber
endHeightnumber

Returns

Promise<BlockInfo_InNode[]>

Defined in

src/ChronikClientNode.ts:121


broadcastTx

broadcastTx(rawTx, skipTokenChecks?): Promise<{ txid: string }>

Broadcasts the rawTx on the network. If skipTokenChecks is false, it will be checked that the tx doesn't burn any tokens before broadcasting.

Parameters

NameTypeDefault value
rawTxstring | Uint8Arrayundefined
skipTokenChecksbooleanfalse

Returns

Promise<{ txid: string }>

Defined in

src/ChronikClientNode.ts:46


broadcastTxs

broadcastTxs(rawTxs, skipTokenChecks?): Promise<{ txids: string[] }>

Broadcasts the rawTxs on the network, only if all of them are valid. If skipTokenChecks is false, it will be checked that the txs don't burn any tokens before broadcasting.

Parameters

NameTypeDefault value
rawTxs(string | Uint8Array)[]undefined
skipTokenChecksbooleanfalse

Returns

Promise<{ txids: string[] }>

Defined in

src/ChronikClientNode.ts:66


chronikInfo

chronikInfo(): Promise<ChronikInfo>

Fetch info about the current running chronik server

Returns

Promise<ChronikInfo>

Defined in

src/ChronikClientNode.ts:91


proxyInterface

proxyInterface(): FailoverProxy

Returns

FailoverProxy

Defined in

src/ChronikClientNode.ts:37


rawTx

rawTx(txid): Promise<RawTx>

Fetch tx details given the txid.

Parameters

NameType
txidstring

Returns

Promise<RawTx>

Defined in

src/ChronikClientNode.ts:147


script

script(scriptType, scriptPayload): ScriptEndpointInNode

Create object that allows fetching script history or UTXOs.

Parameters

NameType
scriptTypeScriptType_InNode
scriptPayloadstring

Returns

ScriptEndpointInNode

Defined in

src/ChronikClientNode.ts:159


token

token(tokenId): Promise<TokenInfo>

Fetch token info and stats given the tokenId.

Parameters

NameType
tokenIdstring

Returns

Promise<TokenInfo>

Defined in

src/ChronikClientNode.ts:133


tokenId

tokenId(tokenId): TokenIdEndpoint

Create object that allows fetching info about a given token

Parameters

NameType
tokenIdstring

Returns

TokenIdEndpoint

Defined in

src/ChronikClientNode.ts:154


tx

tx(txid): Promise<Tx_InNode>

Fetch tx details given the txid.

Parameters

NameType
txidstring

Returns

Promise<Tx_InNode>

Defined in

src/ChronikClientNode.ts:140


ws

ws(config): WsEndpoint_InNode

Open a WebSocket connection to listen for updates.

Parameters

NameType
configWsConfig_InNode

Returns

WsEndpoint_InNode

Defined in

src/ChronikClientNode.ts:182