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
Name | Type | Description |
---|---|---|
urls | string | 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
Throws
throws error on invalid constructor inputs
Defined in
Methods
block
▸ block(hashOrHeight
): Promise
<Block
>
Fetch the block given hash or height.
Parameters
Name | Type |
---|---|
hashOrHeight | string | number |
Returns
Promise
<Block
>
Defined in
blockchainInfo
▸ blockchainInfo(): Promise
<BlockchainInfo
>
Fetch current info of the blockchain, such as tip hash and height.
Returns
Promise
<BlockchainInfo
>
Defined in
blocks
▸ blocks(startHeight
, endHeight
): Promise
<BlockInfo
[]>
Fetch block info of a range of blocks. startHeight
and endHeight
are
inclusive ranges.
Parameters
Name | Type |
---|---|
startHeight | number |
endHeight | number |
Returns
Promise
<BlockInfo
[]>
Defined in
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
Name | Type | Default value |
---|---|---|
rawTx | string | Uint8Array | undefined |
skipSlpCheck | boolean | false |
Returns
Promise
<{ txid
: string
}>
Defined in
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
Name | Type | Default value |
---|---|---|
rawTxs | (string | Uint8Array )[] | undefined |
skipSlpCheck | boolean | false |
Returns
Promise
<{ txids
: string
[] }>
Defined in
proxyInterface
▸ proxyInterface(): FailoverProxy
Returns
FailoverProxy
Defined in
script
▸ script(scriptType
, scriptPayload
): ScriptEndpoint
Create object that allows fetching script history or UTXOs.
Parameters
Name | Type |
---|---|
scriptType | ScriptType |
scriptPayload | string |
Returns
Defined in
token
▸ token(tokenId
): Promise
<Token
>
Fetch token info and stats given the tokenId.
Parameters
Name | Type |
---|---|
tokenId | string |
Returns
Promise
<Token
>
Defined in
tx
▸ tx(txid
): Promise
<Tx
>
Fetch tx details given the txid.
Parameters
Name | Type |
---|---|
txid | string |
Returns
Promise
<Tx
>
Defined in
validateUtxos
▸ validateUtxos(outpoints
): Promise
<UtxoState
[]>
Validate the given outpoints: whether they are unspent, spent or never existed.
Parameters
Name | Type |
---|---|
outpoints | OutPoint [] |
Returns
Promise
<UtxoState
[]>
Defined in
ws
▸ ws(config
): WsEndpoint
Open a WebSocket connection to listen for updates.
Parameters
Name | Type |
---|---|
config | WsConfig |