CCC Docs
    Preparing search index...

    Class ClientPublicMainnet

    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 Summary)

    Index

    Constructors

    Properties

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

    Get fee rate statistics

    Type declaration

      • (blockRange?: NumLike): 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?: null | number): Promise<ClientBlockHeader>
      • Parameters

        • Optionalverbosity: null | number

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

        Returns Promise<ClientBlockHeader>

        BlockHeader

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

    Get block by block number

    Type declaration

      • (
            blockNumber: NumLike,
            verbosity?: null | number,
            withCycles?: null | boolean,
        ): 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

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

    Get block by block hash

    Type declaration

      • (
            blockHash: BytesLike,
            verbosity?: null | number,
            withCycles?: null | boolean,
        ): 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

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

    Get header by block number

    Type declaration

      • (
            blockNumber: NumLike,
            verbosity?: null | number,
        ): 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

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

    Get header by block hash

    Type declaration

      • (
            blockHash: BytesLike,
            verbosity?: null | number,
        ): 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: TransactionLike): Promise<bigint>
      • Parameters

        Returns Promise<bigint>

        Consumed cycles

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

    Test a transaction.

    Type declaration

      • (transaction: TransactionLike, validator?: OutputsValidator): 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?: null | OutputsValidator,
    ) => Promise<`0x${string}`> = ...

    Send a transaction to node.

    Type declaration

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

        • transaction: TransactionLike

          The transaction to send.

        • Optionalvalidator: null | 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

    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 }[];
          },
      >

    • Parameters

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

    • 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 }[];
          },
      >

    • 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 }[];
          },
      >

    • 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;
          },
      >

    • 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 }[];
          },
      >

    • Parameters

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

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

    • Parameters

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

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

    • 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 }[];
          },
      >

    • 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.

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

        An array of input transformers.

      • OptionaloutTransformer: (_: any) => unknown

        An output transformer function.

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

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