Hierarchy

  • Base
    • RPC

Constructors

  • Parameters

    • url: string
    • Optional config: RPCConfig

    Returns RPC

Properties

#private: any
#private: any
addMethod: ((options, config?) => void)

Type declaration

    • (options, config?): void
    • Parameters

      • options: Method
      • Optional config: RPCConfig

      Returns void

addNode: ((peerId, address) => Promise<null>)

Type declaration

    • (peerId, address): Promise<null>
    • Parameters

      • peerId: string

        the peer id of target node

      • address: string

        the address of target node

      Returns Promise<null>

      Method

      addNode

      Memberof

      DefaultRPC

      Description

      attempt to add a node to the peer list and try to connect

calculateDaoMaximumWithdraw: ((outPoint, withdrawBlockHash) => Promise<string>)

Type declaration

    • (outPoint, withdrawBlockHash): Promise<string>
    • Parameters

      • outPoint: OutPoint
      • withdrawBlockHash: string

      Returns Promise<string>

clearBannedAddresses: (() => Promise<null>)

Type declaration

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

      Method

      clearBannedAddresses

      Memberof

      DefaultRPC

      Description

      clear all banned IPs/Subnets

clearTxPool: (() => Promise<null>)

Type declaration

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

      Method

      clearTxPool

      Memberof

      DefaultRPC

      Description

      remove all transactions from the tx pool

createBatchRequest: (<N, P, R>(params?) => any)

Type declaration

    • <N, P, R>(params?): any
    • Type Parameters

      • N extends keyof Base

      • P extends (string | number | object)[]

      • R = any[]

      Parameters

      • Optional params: any

      Returns any

dryRunTransaction: ((tx) => Promise<DryRunResult>)

Type declaration

    • (tx): Promise<DryRunResult>
    • Parameters

      • tx: RawTransaction

      Returns Promise<DryRunResult>

      dry run result, including cycles the transaction used.

      Method

      dryRunTransaction

      Memberof

      DefaultRPC

      Description

      dry run the transaction and return the execution cycles, this method will not check the transaction validaty, but only run the lock script and type script and then return the execution cycles.

estimateCycles: ((tx) => Promise<EstimateCycles>)

Type declaration

    • (tx): Promise<EstimateCycles>
    • Parameters

      Returns Promise<EstimateCycles>

      how many cycles the scripts consume.

      Method

      estimateCycles run a transaction and return the execution consumed cycles This method will not check the transaction validity, but only run the lock script and type script and then return the execution cycles.

getBannedAddresses: (() => Promise<BannedAddresses>)

Type declaration

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

      Method

      getBannedAddresses

      Memberof

      DefaultRPC

      Description

      Returns all banned IPs/Subnets

getBlock: GetBlock<string>

Method

getBlock

Memberof

DefaultRPC

Description

rpc to get block by its hash

Param

Param

Param

Returns

getBlockByNumber: GetBlock<string | bigint>

Method

getBlockByNumber

Memberof

DefaultRPC

Description

rpc to get block by its hash

Param

Param

Param

Returns

getBlockEconomicState: ((blockHash) => Promise<BlockEconomicState>)

Type declaration

getBlockFilter: ((blockHash) => Promise<null | BlockFilter>)

Type declaration

    • (blockHash): Promise<null | BlockFilter>
    • Parameters

      • blockHash: string

        the block hash.

      Returns Promise<null | BlockFilter>

      The block filter by block hash.

      Method

      getBlockFilter

getBlockHash: ((number) => Promise<string>)

Type declaration

    • (number): Promise<string>
    • Parameters

      • number: string | bigint

      Returns Promise<string>

      block hash

      Method

      getBlockHash

      Memberof

      DefaultRPC

      Description

      rpc to get the block hash by block number

getBlockMedianTime: ((blockHash) => Promise<null | string>)

Type declaration

    • (blockHash): Promise<null | string>
    • Parameters

      • blockHash: string

        A median time is calculated for a consecutive block sequence. blockHash indicates the highest block of the sequence.

      Returns Promise<null | string>

      the past median time by block hash. When the given block hash is not on the current canonical chain, this RPC returns null; otherwise returns the median time of the consecutive 37 blocks where the given block_hash has the highest height. Note that the given block is included in the median time. The included block number range is [MAX(block - 36, 0), block].

      Method

      getBlockMedianTime

getBlockchainInfo: (() => Promise<ChainInfo>)

Type declaration

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

      blockchain info, including chain name, difficulty, epoch number, is_intial_block_download, median time, warnings

      Method

      getBlockchainInfo

      Memberof

      DefaultRPC

      Description

      rpc to get state info of the blockchain

getCellbaseOutputCapacityDetails: ((blockHash) => Promise<CellbaseOutputCapacityDetails>)

Type declaration

    • (blockHash): Promise<CellbaseOutputCapacityDetails>
    • Parameters

      • blockHash: string

      Returns Promise<CellbaseOutputCapacityDetails>

      Method

      getCellbaseOutputCapacityDetails

      Memberof

      DefaultRPC

      Description

      Returns each component of the created CKB in this block's cellbase, which is issued to a block N - 1 - ProposalWindow.farthest, where this block's height is N.

      Deprecated

      will be removed from v0.41.0

getCells: (<WithData>(searchKey, order, limit, cursor?) => Promise<GetLiveCellsResult<WithData>>)

Type declaration

    • <WithData>(searchKey, order, limit, cursor?): Promise<GetLiveCellsResult<WithData>>
    • Type Parameters

      • WithData extends boolean = true

      Parameters

      • searchKey: GetCellsSearchKey<WithData>
      • order: Order

        order cells by blocknumber "asc" or "desc"

      • limit: string | bigint

        limit the number of cells returned per call

      • Optional cursor: string

      Returns Promise<GetLiveCellsResult<WithData>>

      CKBComponents.GetLiveCellsResult

      Method

      getCells

      Memberof

      DefaultRPC

      Description

      rpc to get a cell by script

getCellsCapacity: ((searchKey) => Promise<CellsCapacity>)

Type declaration

    • (searchKey): Promise<CellsCapacity>
    • Parameters

      • searchKey: SearchKey

      Returns Promise<CellsCapacity>

      CKBComponents.CellsCapacity

      Method

      getCellsCapacity

      Memberof

      DefaultRPC

      Description

      rpc to get capacities by script

getConsensus: (() => Promise<Consensus>)

Type declaration

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

      consensus parameters

      Method

      getConsensus

      Memberof

      DefaultRPC

      Description

      return various consensus parameters.

getCurrentEpoch: (() => Promise<Epoch>)

Type declaration

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

      epoch info, including block reward, difficulty, last_block_hash_in_previous_epoch, length, number, remainder reward, start number

      Method

      getCurrentEpoch

      Memberof

      DefaultRPC

      Description

      rpc to get the epoch info about the current epoch

getDeploymentsInfo: (() => Promise<DeploymentsInfo>)

Type declaration

getEpochByNumber: ((epoch) => Promise<Epoch>)

Type declaration

    • (epoch): Promise<Epoch>
    • Parameters

      • epoch: string | bigint

      Returns Promise<Epoch>

      epoch info

      Method

      getEpochByNumber

      Memberof

      DefaultRPC

      Description

      rpc to get the epoch info by its number

getFeeRateStatics: ((target?) => Promise<FeeRateStatistics>)

Type declaration

    • (target?): Promise<FeeRateStatistics>
    • Parameters

      • Optional target: string

        Specify the number (1 - 101) of confirmed blocks to be counted. If the number is even, automatically add one. If not specified, defaults to 2

      Returns Promise<FeeRateStatistics>

      the feeRate statistics of confirmed blocks on the chain

      Method

      getFeeRateStatics

      Deprecated

      Please use getFeeRateStatistics instead

getFeeRateStatistics: ((target?) => Promise<FeeRateStatistics>)

Type declaration

    • (target?): Promise<FeeRateStatistics>
    • Parameters

      • Optional target: string

        Specify the number (1 - 101) of confirmed blocks to be counted. If the number is even, automatically add one. If not specified, defaults to 2

      Returns Promise<FeeRateStatistics>

      the feeRate statistics of confirmed blocks on the chain If the query finds the corresponding historical data, the corresponding statistics are returned, containing the mean and median, in shannons per kilo-weight. If not, it returns null.

      Method

      getFeeRateStatistics

getHeader: GetHeader<string>

Method

getHeader

Memberof

DefaultRPC

Description

Returns the information about a block header by hash.

Params

block hash

getHeaderByNumber: GetHeader<string | bigint>

Method

getHeaderByNumber

Memberof

DefaultRPC

Description

Returns the information about a block header by block number

Params

block number

getIndexerTip: (() => Promise<Tip>)

Type declaration

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

      tip info, including block number, block hash

      Method

      getIndexerTip

      Memberof

      DefaultRPC

      Description

      rpc to get tip info of the longest blockchain

getLiveCell: ((outPoint, withData) => Promise<{
    cell: LiveCell;
    status: CellStatus;
}>)

Type declaration

    • (outPoint, withData): Promise<{
          cell: LiveCell;
          status: CellStatus;
      }>
    • Parameters

      • outPoint: OutPoint

        cell's outPoint

      • withData: boolean

        set withData to true to return cell data and data hash if the cell is live

      Returns Promise<{
          cell: LiveCell;
          status: CellStatus;
      }>

      liveCellWithStatus

      Method

      getLiveCell

      Memberof

      DefaultRPC

      Description

      rpc to get a cell by outPoint, the meaning of outPoint could be found in ckb-types, please distinguish outPoint and cellOutPoint

getPeers: (() => Promise<RemoteNode[]>)

Type declaration

    • (): Promise<RemoteNode[]>
    • Returns Promise<RemoteNode[]>

      peers' node info

      Method

      getPeers

      Memberof

      DefaultRPC

      Description

      rpc to get connected peers info

      Deprecated

      will be removed from v0.41.0

getTipBlockNumber: (() => Promise<string>)

Type declaration

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

      block number

      Method

      getTipBlockNumber

      Memberof

      DefaultRPC

      Description

      rpc to get the number of blocks in the longest blockchain

getTipHeader: (() => Promise<Header>)

Type declaration

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

      block header

      Method

      getTipHeader

      Memberof

      DefaultRPC

      Description

      rpc to get the tip header of the longeest blockchain

getTransaction: GetTransaction

Method

getTransaction

Memberof

DefaultRPC

Description

rpc to get trasnaction wtih its status by its hash

Param

the transaction hash of the target transaction

Returns

transaction object with transaction status

getTransactionAndWitnessProof: ((txHashes, blockHash?) => Promise<TransactionAndWitnessProof>)

Type declaration

    • (txHashes, blockHash?): Promise<TransactionAndWitnessProof>
    • Parameters

      • txHashes: string[]

        Transaction hashes, all transactions must be in the same block

      • Optional blockHash: string

        An optional parameter, if specified, looks for transactions in the block with this hash

      Returns Promise<TransactionAndWitnessProof>

      a Merkle proof of transactions’ witness included in a block

      Method

      getTransactionAndWitnessProof

getTransactionProof: ((transactionHashes, blockHash?) => Promise<TransactionProof>)

Type declaration

    • (transactionHashes, blockHash?): Promise<TransactionProof>
    • Parameters

      • transactionHashes: string[]

        transaction hashes, all transactions must be in the same block

      • Optional blockHash: string

        if specified, looks for transactions in the block with this hash

      Returns Promise<TransactionProof>

      Method

      getTransactionProof

      Memberof

      DefaultRPC

      Description

      request merkle proof that transactions are included in a block

getTransactions: (<Group>(searchKey, order, limit, cursor?) => Promise<GetTransactionsResult<Group>>)

Type declaration

    • <Group>(searchKey, order, limit, cursor?): Promise<GetTransactionsResult<Group>>
    • Type Parameters

      • Group extends boolean = false

      Parameters

      • searchKey: GetTransactionsSearchKey<Group>
      • order: Order

        order cells by blocknumber "asc" or "desc"

      • limit: string | bigint

        limit the number of cells returned per call

      • Optional cursor: string

      Returns Promise<GetTransactionsResult<Group>>

      CKBComponents.GetTransactionsResult

      Method

      getTransactions

      Memberof

      DefaultRPC

      Description

      rpc to get a transactions by script

localNodeInfo: (() => Promise<LocalNode>)

Type declaration

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

      node info, including addresses, is_outbound, node id, and version

      Method

      localNodeInfo

      Memberof

      DefaultRPC

      Description

      rpc to get the local node information

pingPeers: (() => Promise<null>)

Type declaration

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

      Method

      pingPeers

      Memberof

      DefaultRPC

      Description

      request a ping sent to all connected peers to measure ping time

removeNode: ((peerId) => Promise<null>)

Type declaration

    • (peerId): Promise<null>
    • Parameters

      • peerId: string

        the peer id of the target node

      Returns Promise<null>

      Method

      removeNode

      Memberof

      DefaultRPC

      Description

      attempt to remove a node from the peer list and try to disconnect

sendTransaction: ((tx, outputsValidator?) => Promise<string>)

Type declaration

    • (tx, outputsValidator?): Promise<string>
    • Parameters

      • tx: RawTransaction
      • Optional outputsValidator: OutputsValidator

        Validates the transaction outputs before entering the tx-pool, an optional string parameter (enum: default | passthrough ), null and passthrough mean skipping outputs validation

      Returns Promise<string>

      transaction hash

      Method

      sendTransaction

      Memberof

      DefaultRPC

      Description

      rpc to send a new transaction into transaction pool

setBan: ((address, command, banTime, absolute?, reason?) => Promise<null>)

Type declaration

    • (address, command, banTime, absolute?, reason?): Promise<null>
    • Parameters

      • address: string
      • command: "insert" | "delete"
      • banTime: null | string
      • Optional absolute: boolean
      • Optional reason: string

      Returns Promise<null>

      Method

      setBan

      Memberof

      DefaultRPC

      Description

      insert or delete an IP/Subnet from the banned list

setNetworkActive: ((state) => Promise<null>)

Type declaration

    • (state): Promise<null>
    • Parameters

      • state: boolean

        true to enable networking, false to disable

      Returns Promise<null>

      Method

      setNetworkActive

      Memberof

      DefaultRPC

      Description

      disable/enable all p2p network activity

syncState: (() => Promise<SyncState>)

Type declaration

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

      Method

      syncState

      Memberof

      DefaultRPC

      Description

      return sync state of this node

txPoolInfo: (() => Promise<TxPoolInfo>)

Type declaration

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

      info of transaction pool, including last_txs_updated_at, number of orphan, number of pending, number of proposed

      Method

      txPoolInfo

      Memberof

      DefaultRPC

      Description

      rpc to get pool information

verifyTransactionAndWitnessProof: ((txProof) => Promise<string[]>)

Type declaration

    • (txProof): Promise<string[]>
    • Parameters

      Returns Promise<string[]>

      the transaction hashes it commits to

      Method

      verifyTransactionAndWitnessProof

      Description

      Verifies that a proof points to transactions in a block

verifyTransactionProof: ((transactionProof) => Promise<string[]>)

Type declaration

    • (transactionProof): Promise<string[]>
    • Parameters

      Returns Promise<string[]>

      hash list of transactions committed in the block

      Method

      verifyTransactionProof

      Memberof

      DefaultRPC

      Description

      verifies that a proof points to transactions in a block, returns transactions it commits to.

Accessors

  • get node(): Node
  • Returns Node

  • get paramsFormatter(): {
        toArray: ((format?) => ((arg) => any));
        toBoolean: ((value) => boolean);
        toCellDep: ((cellDep) => CellDep);
        toDepType: ((type) => "code" | "dep_group");
        toGetCellsSearchKey: ((data) => GetCellsSearchKey);
        toGetTransactionsSearchKey: ((data) => GetTransactionsSearchKey);
        toHash: ((hash) => string);
        toInput: ((input) => CellInput);
        toNumber: ((number) => string);
        toOptional: ((format?) => ((arg) => any));
        toOrder: ((order) => Order);
        toOutPoint: ((outPoint) => OutPoint);
        toOutput: ((output) => CellOutput);
        toOutputsValidator: ((outputsValidator) => undefined | "default" | "passthrough");
        toPageNumber: ((pageNo?) => string);
        toPageSize: ((pageSize?) => string);
        toRawTransaction: ((transaction) => RawTransaction);
        toReverseOrder: ((reverse?) => boolean);
        toScript: ((script) => Script);
        toSearchFilter: ((data) => SearchFilter);
        toSearchKey: ((data) => SearchKey);
        toTransactionAndWitnessProof: ((proof) => TransactionAndWitnessProof);
        toTransactionProof: ((proof) => TransactionProof);
    }
  • Returns {
        toArray: ((format?) => ((arg) => any));
        toBoolean: ((value) => boolean);
        toCellDep: ((cellDep) => CellDep);
        toDepType: ((type) => "code" | "dep_group");
        toGetCellsSearchKey: ((data) => GetCellsSearchKey);
        toGetTransactionsSearchKey: ((data) => GetTransactionsSearchKey);
        toHash: ((hash) => string);
        toInput: ((input) => CellInput);
        toNumber: ((number) => string);
        toOptional: ((format?) => ((arg) => any));
        toOrder: ((order) => Order);
        toOutPoint: ((outPoint) => OutPoint);
        toOutput: ((output) => CellOutput);
        toOutputsValidator: ((outputsValidator) => undefined | "default" | "passthrough");
        toPageNumber: ((pageNo?) => string);
        toPageSize: ((pageSize?) => string);
        toRawTransaction: ((transaction) => RawTransaction);
        toReverseOrder: ((reverse?) => boolean);
        toScript: ((script) => Script);
        toSearchFilter: ((data) => SearchFilter);
        toSearchKey: ((data) => SearchKey);
        toTransactionAndWitnessProof: ((proof) => TransactionAndWitnessProof);
        toTransactionProof: ((proof) => TransactionProof);
    }

    • toArray: ((format?) => ((arg) => any))
        • (format?): ((arg) => any)
        • Parameters

          • Optional format: ((args) => any)
              • (args): any
              • Parameters

                • args: any

                Returns any

          Returns ((arg) => any)

            • (arg): any
            • Parameters

              • arg: any

              Returns any

    • toBoolean: ((value) => boolean)
        • (value): boolean
        • Parameters

          • value: boolean

          Returns boolean

    • toCellDep: ((cellDep) => CellDep)
        • (cellDep): CellDep
        • Parameters

          Returns CellDep

    • toDepType: ((type) => "code" | "dep_group")
        • (type): "code" | "dep_group"
        • Parameters

          • type: DepType

          Returns "code" | "dep_group"

    • toGetCellsSearchKey: ((data) => GetCellsSearchKey)
        • (data): GetCellsSearchKey
        • Parameters

          • data: GetCellsSearchKey<boolean>

          Returns GetCellsSearchKey

    • toGetTransactionsSearchKey: ((data) => GetTransactionsSearchKey)
        • (data): GetTransactionsSearchKey
        • Parameters

          • data: GetTransactionsSearchKey<boolean>

          Returns GetTransactionsSearchKey

    • toHash: ((hash) => string)
        • (hash): string
        • Parameters

          • hash: string

          Returns string

    • toInput: ((input) => CellInput)
        • (input): CellInput
        • Parameters

          Returns CellInput

    • toNumber: ((number) => string)
        • (number): string
        • Parameters

          • number: string | bigint

          Returns string

    • toOptional: ((format?) => ((arg) => any))
        • (format?): ((arg) => any)
        • Parameters

          • Optional format: ((args) => any)
              • (args): any
              • Parameters

                • args: any

                Returns any

          Returns ((arg) => any)

            • (arg): any
            • Parameters

              • arg: any

              Returns any

    • toOrder: ((order) => Order)
        • (order): Order
        • Parameters

          • order: Order

          Returns Order

    • toOutPoint: ((outPoint) => OutPoint)
        • (outPoint): OutPoint
        • Parameters

          Returns OutPoint

    • toOutput: ((output) => CellOutput)
        • (output): CellOutput
        • Parameters

          Returns CellOutput

    • toOutputsValidator: ((outputsValidator) => undefined | "default" | "passthrough")
        • (outputsValidator): undefined | "default" | "passthrough"
        • Parameters

          • outputsValidator: OutputsValidator

          Returns undefined | "default" | "passthrough"

    • toPageNumber: ((pageNo?) => string)
        • (pageNo?): string
        • Parameters

          • Optional pageNo: string | bigint

          Returns string

    • toPageSize: ((pageSize?) => string)
        • (pageSize?): string
        • Parameters

          • Optional pageSize: string | bigint

          Returns string

    • toRawTransaction: ((transaction) => RawTransaction)
        • (transaction): RawTransaction
        • Parameters

          • transaction: RawTransaction

          Returns RawTransaction

    • toReverseOrder: ((reverse?) => boolean)
        • (reverse?): boolean
        • Parameters

          • Optional reverse: boolean

          Returns boolean

    • toScript: ((script) => Script)
        • (script): Script
        • Parameters

          Returns Script

    • toSearchFilter: ((data) => SearchFilter)
        • (data): SearchFilter
        • Parameters

          • data: SearchFilter

          Returns SearchFilter

    • toSearchKey: ((data) => SearchKey)
        • (data): SearchKey
        • Parameters

          • data: SearchKey

          Returns SearchKey

    • toTransactionAndWitnessProof: ((proof) => TransactionAndWitnessProof)
        • (proof): TransactionAndWitnessProof
        • Parameters

          • proof: TransactionAndWitnessProof

          Returns TransactionAndWitnessProof

    • toTransactionProof: ((proof) => TransactionProof)
        • (proof): TransactionProof
        • Parameters

          Returns TransactionProof

  • get resultFormatter(): __module
  • Returns __module

  • get rpcProperties(): RpcPropertes
  • Returns RpcPropertes

Methods

  • Parameters

    • blockHash: string

      the fork block hash.

    • Optional verbosity: "0x2" | 2n

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

    Returns Promise<null | BlockView>

    a fork block or null. When the RPC returns a block, the block hash must equal to the parameter blockHash. Please note that due to the technical nature of the peer to peer sync, the RPC may return null or a fork block result on different nodes with same block_hash even they are fully synced to the canonical chain. And because of chain reorganization, for the same block_hash, the RPC may sometimes return null and sometimes return the fork block. When verbosity is 2, it returns a JSON object as the result. See BlockView for the schema. When verbosity is 0, it returns a 0x-prefixed hex string as the result. The string encodes the block serialized by molecule using schema table Block.

    Method

    getForkBlock

  • Parameters

    • blockHash: string
    • verbosity: 0n | "0x0"

    Returns Promise<null | string>

  • Returns Promise<TxPoolIds>

    CKBComponents.RawTxPool

    Method

    getRawTxPool

    Memberof

    DefaultRPC

    Description

    Returns all transaction ids in tx pool as a json array of string transaction ids.

  • Parameters

    • verbose: true

    Returns Promise<TxPoolVerbosity>

  • Parameters

    • verbose: null | false

    Returns Promise<TxPoolIds>

  • Parameters

    • node: Node

    Returns Node

Generated using TypeDoc