An abstract class implementing JSON-RPC client functionality for a specific URL and timeout. Provides methods for sending transactions and building JSON-RPC payloads.

Hierarchy (view full)

Constructors

Properties

getFeeRateStatistics: ((blockRange?: NumLike) => Promise<{
    mean: bigint;
    median: bigint;
}>) = ...

Get fee rate statistics

Type declaration

    • (blockRange?): Promise<{
          mean: bigint;
          median: bigint;
      }>
    • Parameters

      Returns Promise<{
          mean: bigint;
          median: bigint;
      }>

      Fee rate statistics

getTip: (() => Promise<bigint>) = ...

Get tip block number

Type declaration

    • (): Promise<bigint>
    • Returns Promise<bigint>

      Tip block number

getTipHeader: ((verbosity?: null | number) => Promise<ClientBlockHeader>) = ...

Get tip block header

Type declaration

    • (verbosity?): Promise<ClientBlockHeader>
    • Parameters

      • Optionalverbosity: null | number

        result format which allows 0 and 1. (Optional, the default is 1.)

      Returns Promise<ClientBlockHeader>

      BlockHeader

getBlockByNumber: ((blockNumber: NumLike, verbosity?: null | number, withCycles?: null | boolean) => Promise<undefined | ClientBlock>) = ...

Get block by block number

Type declaration

    • (blockNumber, verbosity?, withCycles?): Promise<undefined | ClientBlock>
    • Parameters

      • blockNumber: NumLike

        The block number.

      • Optionalverbosity: null | number

        result format which allows 0 and 2. (Optional, the default is 2.)

      • OptionalwithCycles: null | boolean

        whether the return cycles of block transactions. (Optional, default false.)

      Returns Promise<undefined | ClientBlock>

      Block

getBlockByHash: ((blockHash: BytesLike, verbosity?: null | number, withCycles?: null | boolean) => Promise<undefined | ClientBlock>) = ...

Get block by block hash

Type declaration

    • (blockHash, verbosity?, withCycles?): Promise<undefined | ClientBlock>
    • Parameters

      • blockHash: BytesLike

        The block hash.

      • Optionalverbosity: null | number

        result format which allows 0 and 2. (Optional, the default is 2.)

      • OptionalwithCycles: null | boolean

        whether the return cycles of block transactions. (Optional, default false.)

      Returns Promise<undefined | ClientBlock>

      Block

getHeaderByNumber: ((blockNumber: NumLike, verbosity?: null | number) => Promise<undefined | ClientBlockHeader>) = ...

Get header by block number

Type declaration

    • (blockNumber, verbosity?): Promise<undefined | ClientBlockHeader>
    • Parameters

      • blockNumber: NumLike

        The block number.

      • Optionalverbosity: null | number

        result format which allows 0 and 1. (Optional, the default is 1.)

      Returns Promise<undefined | ClientBlockHeader>

      BlockHeader

getHeaderByHash: ((blockHash: BytesLike, verbosity?: null | number) => Promise<undefined | ClientBlockHeader>) = ...

Get header by block hash

Type declaration

    • (blockHash, verbosity?): Promise<undefined | ClientBlockHeader>
    • Parameters

      • blockHash: BytesLike

        The block hash.

      • Optionalverbosity: null | number

        result format which allows 0 and 1. (Optional, the default is 1.)

      Returns Promise<undefined | ClientBlockHeader>

      BlockHeader

estimateCycles: ((transaction: TransactionLike) => Promise<bigint>) = ...

Estimate cycles of a transaction.

Type declaration

    • (transaction): Promise<bigint>
    • Parameters

      Returns Promise<bigint>

      Consumed cycles

sendTransactionDry: ((transaction: TransactionLike, validator?: OutputsValidator) => Promise<bigint>) = ...

Test a transaction.

Type declaration

    • (transaction, validator?): Promise<bigint>
    • Parameters

      • transaction: TransactionLike

        The transaction to test.

      • Optionalvalidator: OutputsValidator

        "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.

      Returns Promise<bigint>

      Consumed cycles

sendTransactionNoCache: ((transaction: TransactionLike, validator?: OutputsValidator) => Promise<`0x${string}`>) = ...

Send a transaction to node.

Type declaration

    • (transaction, validator?): Promise<`0x${string}`>
    • Parameters

      • transaction: TransactionLike

        The transaction to send.

      • Optionalvalidator: OutputsValidator

        "passthrough": Disable validation. "well_known_scripts_only": Only accept well known scripts in the transaction.

      Returns Promise<`0x${string}`>

      Transaction hash.

getTransactionNoCache: ((txHash: BytesLike) => Promise<undefined | ClientTransactionResponse>) = ...

Get a transaction from node.

Type declaration

findCellsPagedNoCache: ((key: ClientIndexerSearchKeyLike, order?: "asc" | "desc", limit?: NumLike, after?: string) => Promise<ClientFindCellsResponse>) = ...

find cells from node.

Type declaration

findTransactionsPaged: {
    (key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
        groupByTransaction: true;
    }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsGroupedResponse>;
    (key: Omit<ClientIndexerSearchKeyTransactionLike, "groupByTransaction"> & {
        groupByTransaction?: null | false;
    }, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse>;
    (key: ClientIndexerSearchKeyTransactionLike, order?: "asc" | "desc", limit?: NumLike, after?: string): Promise<ClientFindTransactionsResponse | ClientFindTransactionsGroupedResponse>;
} = ...

find transactions from node.

The search key of transactions.

The order of transactions.

The max return size of transactions.

Pagination parameter.

The found transactions.

getCellsCapacity: ((key: ClientIndexerSearchKeyLike) => Promise<bigint>) = ...

get cells capacity from node.

Type declaration

    • (key): Promise<bigint>
    • Parameters

      Returns Promise<bigint>

      The sum of cells capacity.

Accessors

  • get url(): string
  • Returns the URL of the JSON-RPC server.

    Returns string

    The URL of the JSON-RPC server.

Methods

  • Parameters

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        cells: {
            isInput: boolean;
            cellIndex: bigint;
        }[];
    }, any, unknown>

  • Parameters

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        isInput: boolean;
        cellIndex: bigint;
    }, any, unknown>

  • Parameters

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        isInput: boolean;
        cellIndex: bigint;
    } | {
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        cells: {
            isInput: boolean;
            cellIndex: bigint;
        }[];
    }, any, unknown>

  • Parameters

    • lock: ScriptLike
    • type: undefined | null | ScriptLike
    • groupByTransaction: true
    • Optionalorder: "asc" | "desc"
    • Optionallimit: number

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        cells: {
            isInput: boolean;
            cellIndex: bigint;
        }[];
    }, any, unknown>

  • Parameters

    • lock: ScriptLike
    • Optionaltype: null | ScriptLike
    • OptionalgroupByTransaction: null | false
    • Optionalorder: "asc" | "desc"
    • Optionallimit: number

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        isInput: boolean;
        cellIndex: bigint;
    }, any, unknown>

  • Parameters

    • lock: ScriptLike
    • Optionaltype: null | ScriptLike
    • OptionalgroupByTransaction: null | boolean
    • Optionalorder: "asc" | "desc"
    • Optionallimit: number

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        isInput: boolean;
        cellIndex: bigint;
    } | {
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        cells: {
            isInput: boolean;
            cellIndex: bigint;
        }[];
    }, any, unknown>

  • Parameters

    • type: ScriptLike
    • groupByTransaction: true
    • Optionalorder: "asc" | "desc"
    • Optionallimit: number

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        cells: {
            isInput: boolean;
            cellIndex: bigint;
        }[];
    }, any, unknown>

  • Parameters

    • type: ScriptLike
    • OptionalgroupByTransaction: null | false
    • Optionalorder: "asc" | "desc"
    • Optionallimit: number

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        isInput: boolean;
        cellIndex: bigint;
    }, any, unknown>

  • Parameters

    • type: ScriptLike
    • OptionalgroupByTransaction: null | boolean
    • Optionalorder: "asc" | "desc"
    • Optionallimit: number

    Returns AsyncGenerator<{
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        isInput: boolean;
        cellIndex: bigint;
    } | {
        txHash: `0x${string}`;
        blockNumber: bigint;
        txIndex: bigint;
        cells: {
            isInput: boolean;
            cellIndex: bigint;
        }[];
    }, any, unknown>

  • Get a live cell from node.

    Parameters

    • outPoint: OutPointLike

      The out point of the cell.

    • OptionalwithData: null | boolean

      Include data in the response.

    • OptionalincludeTxPool: null | boolean

      Include cells in the tx pool.

    Returns Promise<undefined | Cell>

    The cell

  • Builds a sender function for a JSON-RPC method.

    Parameters

    • rpcMethod: string

      The JSON-RPC method.

    • inTransformers: (undefined | ((_: any) => unknown))[]

      An array of input transformers.

    • OptionaloutTransformer: ((_: any) => unknown)

      An output transformer function.

        • (_): unknown
        • Parameters

          • _: any

          Returns unknown

    Returns ((...req: unknown[]) => Promise<unknown>)

    A function that sends a JSON-RPC request with the given method and transformed parameters.

      • (...req): Promise<unknown>
      • Parameters

        • Rest...req: unknown[]

        Returns Promise<unknown>

  • Sends a JSON-RPC request to the server.

    Parameters

    Returns Promise<unknown>

    The result of the JSON-RPC request.

    Will throw an error if the response ID does not match the request ID, or if the response contains an error.