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
Name | Type | Description |
---|---|---|
urls | string [] | 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
Throws
throws error on invalid constructor inputs
Defined in
Methods
address
▸ address(address
): ScriptEndpointInNode
Create object that allows fetching script history or UTXOs by p2pkh or p2sh address
Parameters
Name | Type |
---|---|
address | string |
Returns
Defined in
block
▸ block(hashOrHeight
): Promise
<Block_InNode
>
Fetch the block given hash or height.
Parameters
Name | Type |
---|---|
hashOrHeight | string | number |
Returns
Promise
<Block_InNode
>
Defined in
blockTxs
▸ blockTxs(hashOrHeight
, page?
, pageSize?
): Promise
<TxHistoryPage_InNode
>
Fetch the tx history of a block given hash or height.
Parameters
Name | Type | Default value |
---|---|---|
hashOrHeight | string | number | undefined |
page | number | 0 |
pageSize | number | 25 |
Returns
Promise
<TxHistoryPage_InNode
>
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_InNode
[]>
Fetch block info of a range of blocks.
startHeight
and endHeight
are inclusive ranges.
Parameters
Name | Type |
---|---|
startHeight | number |
endHeight | number |
Returns
Promise
<BlockInfo_InNode
[]>
Defined in
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
Name | Type | Default value |
---|---|---|
rawTx | string | Uint8Array | undefined |
skipTokenChecks | boolean | false |
Returns
Promise
<{ txid
: string
}>
Defined in
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
Name | Type | Default value |
---|---|---|
rawTxs | (string | Uint8Array )[] | undefined |
skipTokenChecks | boolean | false |
Returns
Promise
<{ txids
: string
[] }>
Defined in
chronikInfo
▸ chronikInfo(): Promise
<ChronikInfo
>
Fetch info about the current running chronik server
Returns
Promise
<ChronikInfo
>
Defined in
proxyInterface
▸ proxyInterface(): FailoverProxy
Returns
FailoverProxy
Defined in
rawTx
▸ rawTx(txid
): Promise
<RawTx
>
Fetch tx details given the txid.
Parameters
Name | Type |
---|---|
txid | string |
Returns
Promise
<RawTx
>
Defined in
script
▸ script(scriptType
, scriptPayload
): ScriptEndpointInNode
Create object that allows fetching script history or UTXOs.
Parameters
Name | Type |
---|---|
scriptType | ScriptType_InNode |
scriptPayload | string |
Returns
Defined in
token
▸ token(tokenId
): Promise
<TokenInfo
>
Fetch token info and stats given the tokenId.
Parameters
Name | Type |
---|---|
tokenId | string |
Returns
Promise
<TokenInfo
>
Defined in
tokenId
▸ tokenId(tokenId
): TokenIdEndpoint
Create object that allows fetching info about a given token
Parameters
Name | Type |
---|---|
tokenId | string |
Returns
Defined in
tx
▸ tx(txid
): Promise
<Tx_InNode
>
Fetch tx details given the txid.
Parameters
Name | Type |
---|---|
txid | string |
Returns
Promise
<Tx_InNode
>
Defined in
ws
▸ ws(config
): WsEndpoint_InNode
Open a WebSocket connection to listen for updates.
Parameters
Name | Type |
---|---|
config | WsConfig_InNode |