Skip to main content

Class: ChronikClient

Client to access a Chronik instance.Plain object, without any connections.

Constructors

constructor

new ChronikClient(urls): ChronikClient

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

Parameters

NameTypeDescription
urlsstring | string[]This param can be either an array of url strings or a singular url string. A valid url comes with schema and without a trailing slash. e.g. 'https://chronik.be.cash/xec' or '['https://chronik.be.cash/xec', 'https://chronik.fabien.cash'] The approach of accepting an array of urls as input is to ensure redundancy if the first url encounters downtime. The single url string input will eventually be deprecated for url arrays regardless of one or many urls being supplied.

Returns

ChronikClient

Throws

throws error on invalid constructor inputs

Defined in

src/ChronikClient.ts:31

Methods

block

block(hashOrHeight): Promise<Block>

Fetch the block given hash or height.

Parameters

NameType
hashOrHeightstring | number

Returns

Promise<Block>

Defined in

src/ChronikClient.ts:91


blockchainInfo

blockchainInfo(): Promise<BlockchainInfo>

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

Returns

Promise<BlockchainInfo>

Defined in

src/ChronikClient.ts:84


blocks

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

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

Parameters

NameType
startHeightnumber
endHeightnumber

Returns

Promise<BlockInfo[]>

Defined in

src/ChronikClient.ts:101


broadcastTx

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

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

Parameters

NameTypeDefault value
rawTxstring | Uint8Arrayundefined
skipSlpCheckbooleanfalse

Returns

Promise<{ txid: string }>

Defined in

src/ChronikClient.ts:46


broadcastTxs

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

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

Parameters

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

Returns

Promise<{ txids: string[] }>

Defined in

src/ChronikClient.ts:66


proxyInterface

proxyInterface(): FailoverProxy

Returns

FailoverProxy

Defined in

src/ChronikClient.ts:37


script

script(scriptType, scriptPayload): ScriptEndpoint

Create object that allows fetching script history or UTXOs.

Parameters

NameType
scriptTypeScriptType
scriptPayloadstring

Returns

ScriptEndpoint

Defined in

src/ChronikClient.ts:150


token

token(tokenId): Promise<Token>

Fetch token info and stats given the tokenId.

Parameters

NameType
tokenIdstring

Returns

Promise<Token>

Defined in

src/ChronikClient.ts:120


tx

tx(txid): Promise<Tx>

Fetch tx details given the txid.

Parameters

NameType
txidstring

Returns

Promise<Tx>

Defined in

src/ChronikClient.ts:113


validateUtxos

validateUtxos(outpoints): Promise<UtxoState[]>

Validate the given outpoints: whether they are unspent, spent or never existed.

Parameters

NameType
outpointsOutPoint[]

Returns

Promise<UtxoState[]>

Defined in

src/ChronikClient.ts:130


ws

ws(config): WsEndpoint

Open a WebSocket connection to listen for updates.

Parameters

NameType
configWsConfig

Returns

WsEndpoint

Defined in

src/ChronikClient.ts:162