Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CKBRPC

Hierarchy

Index

Constructors

constructor

  • Parameters

    • url: string
    • Default value config: RPCConfig = { timeout: 30000 }

    Returns CKBRPC

Properties

addNode

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

addNode

memberof

DefaultRPC

description

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

param

the peer id of target node

param

the address of target node

returns

Type declaration

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

      • peerId: string
      • address: string

      Returns Promise<null>

calculateDaoMaximumWithdraw

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

Type declaration

clearBannedAddresses

clearBannedAddresses: () => Promise<null>
method

clearBannedAddresses

memberof

DefaultRPC

description

clear all banned IPs/Subnets

returns

Type declaration

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

clearTxPool

clearTxPool: () => Promise<null>
method

clearTxPool

memberof

DefaultRPC

description

remove all transactions from the tx pool

returns

Type declaration

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

dryRunTransaction

dryRunTransaction: (tx: RawTransaction) => Promise<RunDryResult>
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.

param

the raw transaction whose cycles is going to be calculated

returns

dry run result, including cycles the transaction used.

Type declaration

estimateCycles

estimateCycles: (tx: Transaction) => Promise<EstimateCycles>
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.

param
returns

how many cycles the scripts consume.

Type declaration

getBannedAddresses

getBannedAddresses: () => Promise<BannedAddresses>
method

getBannedAddresses

memberof

DefaultRPC

description

Returns all banned IPs/Subnets

Type declaration

getBlock

getBlock: (hash: Hash) => Promise<Block>
method

getBlock

memberof

DefaultRPC

description

rpc to get block by its hash

param

the block hash of the target block

returns

block object

Type declaration

getBlockByNumber

getBlockByNumber: (number: BlockNumber | bigint) => Promise<Block>
method

getBlockByNumber

memberof

DefaultRPC

description

rpc to get block by its number

param

the block number of the target block

returns

block object

Type declaration

getBlockEconomicState

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

getBlockEconomicState

memberof

DefaultRPC

description
param
returns

Type declaration

getBlockFilter

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

getBlockFilter

param

the block hash.

returns

The block filter by block hash.

Type declaration

getBlockHash

getBlockHash: (number: BlockNumber | bigint) => Promise<Hash>
method

getBlockHash

memberof

DefaultRPC

description

rpc to get the block hash by block number

param

block hash

returns

block hash

Type declaration

getBlockMedianTime

getBlockMedianTime: (blockHash: Hash256) => Promise<Timestamp | null>
method

getBlockMedianTime

param

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

returns

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

Type declaration

getBlockchainInfo

getBlockchainInfo: () => Promise<BlockchainInfo>
method

getBlockchainInfo

memberof

DefaultRPC

description

rpc to get state info of the blockchain

returns

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

Type declaration

getCellbaseOutputCapacityDetails

getCellbaseOutputCapacityDetails: (blockHash: Hash) => 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.

param
deprecated

will be removed from v0.41.0

Type declaration

getCells

getCells: <WithData>(searchKey: GetCellsSearchKey<WithData>, order: Order, limit: Hash | bigint, cursor?: Hash256) => Promise<GetLiveCellsResult<WithData>>
method

getCells

memberof

DefaultRPC

description

rpc to get a cell by script

param
param

order cells by blocknumber "asc" or "desc"

param

limit the number of cells returned per call

param
returns

CKBComponents.GetLiveCellsResult

Type declaration

getCellsCapacity

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

getCellsCapacity

memberof

DefaultRPC

description

rpc to get capacities by script

param
returns

CKBComponents.CellsCapacity

Type declaration

getConsensus

getConsensus: () => Promise<Consensus>
method

getConsensus

memberof

DefaultRPC

description

return various consensus parameters.

returns

consensus parameters

Type declaration

getCurrentEpoch

getCurrentEpoch: () => Promise<Epoch>
method

getCurrentEpoch

memberof

DefaultRPC

description

rpc to get the epoch info about the current epoch

returns

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

Type declaration

getEpochByNumber

getEpochByNumber: (epoch: string | bigint) => Promise<Epoch>
method

getEpochByNumber

memberof

DefaultRPC

description

rpc to get the epoch info by its number

returns

epoch info

Type declaration

    • (epoch: string | bigint): Promise<Epoch>
    • Parameters

      • epoch: string | bigint

      Returns Promise<Epoch>

getFeeRateStatics

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

getFeeRateStatics

deprecated

Please use Base.getFeeRateStatistics instead

param

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

the feeRate statistics of confirmed blocks on the chain

Type declaration

getFeeRateStatistics

getFeeRateStatistics: () => Promise<FeeRateStatistics>
method

getFeeRateStatistics

param

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

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.

Type declaration

getHeader

getHeader: (blockHash: Hash) => Promise<BlockHeader>
method

getHeader

memberof

DefaultRPC

description

Returns the information about a block header by hash.

params

{Promise} block hash

Type declaration

getHeaderByNumber

getHeaderByNumber: (blockNumber: BlockNumber | bigint) => Promise<BlockHeader>
method

getHeaderByNumber

memberof

DefaultRPC

description

Returns the information about a block header by block number

params

{Promise} block number

Type declaration

getIndexerTip

getIndexerTip: () => Promise<Tip>
method

getIndexerTip

memberof

DefaultRPC

description

rpc to get tip info of the longest blockchain

returns

tip info, including block number, block hash

Type declaration

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

getLiveCell

getLiveCell: (outPoint: OutPoint, withData: boolean) => Promise<{ cell: LiveCell; status: CellStatus }>
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

param

cell's outPoint

param

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

returns

liveCellWithStatus

Type declaration

getPeers

getPeers: () => Promise<RemoteNodeInfo[]>
method

getPeers

memberof

DefaultRPC

description

rpc to get connected peers info

returns

peers' node info

deprecated

will be removed from v0.41.0

Type declaration

getTipBlockNumber

getTipBlockNumber: () => Promise<BlockNumber>
method

getTipBlockNumber

memberof

DefaultRPC

description

rpc to get the number of blocks in the longest blockchain

returns

block number

Type declaration

getTipHeader

getTipHeader: () => Promise<BlockHeader>
method

getTipHeader

memberof

DefaultRPC

description

rpc to get the tip header of the longeest blockchain

returns

block header

Type declaration

getTransaction

getTransaction: (hash: Hash) => Promise<TransactionWithStatus>
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

Type declaration

getTransactionAndWitnessProof

getTransactionAndWitnessProof: (txHashes: Hash256[], blockHash?: Hash256) => Promise<TransactionAndWitnessProof>
method

getTransactionAndWitnessProof

param

Transaction hashes, all transactions must be in the same block

param

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

returns

a Merkle proof of transactions’ witness included in a block

Type declaration

getTransactionProof

getTransactionProof: (transactionHashes: Hash[], blockHash?: Hash) => Promise<TransactionProof>
method

getTransactionProof

memberof

DefaultRPC

description

request merkle proof that transactions are included in a block

param

transaction hashes, all transactions must be in the same block

param

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

Type declaration

getTransactions

getTransactions: <Group>(searchKey: GetTransactionsSearchKey<Group>, order: Order, limit: Hash | bigint, cursor?: Hash256) => Promise<GetTransactionsResult<Group>>
method

getTransactions

memberof

DefaultRPC

description

rpc to get a transactions by script

param
param

order cells by blocknumber "asc" or "desc"

param

limit the number of cells returned per call

param
returns

CKBComponents.GetTransactionsResult

Type declaration

localNodeInfo

localNodeInfo: () => Promise<LocalNodeInfo>
method

localNodeInfo

memberof

DefaultRPC

description

rpc to get the local node information

returns

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

Type declaration

pingPeers

pingPeers: () => Promise<null>
method

pingPeers

memberof

DefaultRPC

description

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

returns

Type declaration

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

removeNode

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

removeNode

memberof

DefaultRPC

description

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

param

the peer id of the target node

returns

Type declaration

    • (peerId: string): Promise<null>
    • Parameters

      • peerId: string

      Returns Promise<null>

sendTransaction

sendTransaction: (tx: RawTransaction, outputsValidator?: OutputsValidator) => Promise<Hash>
method

sendTransaction

memberof

DefaultRPC

description

rpc to send a new transaction into transaction pool

param

a raw transaction includes cell deps, inputs, outputs, version, and witnesses, detailed info could be found in ckb-types

param

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

returns

transaction hash

Type declaration

setBan

setBan: (address: string, command: "insert" | "delete", banTime: string | null, absolute?: undefined | false | true, reason?: undefined | string) => Promise<null>
method

setBan

memberof

DefaultRPC

description

insert or delete an IP/Subnet from the banned list

param

The IP/Subnet with an optional netmask (default is /32 = single IP)

param

insert to insert an IP/Subnet to the list, delete to delete an IP/Subnet from the list

param

Time in milliseconds how long (or until when if [absolute] is set) the IP is banned, optional parameter, null means using the default time of 24h

param

If set, the ban_time must be an absolute timestamp in milliseconds since epoch, optional parameter

param

Ban reason, optional parameter

Type declaration

    • (address: string, command: "insert" | "delete", banTime: string | null, absolute?: undefined | false | true, reason?: undefined | string): Promise<null>
    • Parameters

      • address: string
      • command: "insert" | "delete"
      • banTime: string | null
      • Optional absolute: undefined | false | true
      • Optional reason: undefined | string

      Returns Promise<null>

setNetworkActive

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

setNetworkActive

memberof

DefaultRPC

description

disable/enable all p2p network activity

param

true to enable networking, false to disable

Type declaration

    • (state: boolean): Promise<null>
    • Parameters

      • state: boolean

      Returns Promise<null>

syncState

syncState: () => Promise<SyncState>
method

syncState

memberof

DefaultRPC

description

return sync state of this node

Type declaration

txPoolInfo

txPoolInfo: () => Promise<TxPoolInfo>
method

txPoolInfo

memberof

DefaultRPC

description

rpc to get pool information

returns

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

Type declaration

verifyTransactionAndWitnessProof

verifyTransactionAndWitnessProof: (txProof: TransactionAndWitnessProof) => Promise<Hash256[]>
method

verifyTransactionAndWitnessProof

description

Verifies that a proof points to transactions in a block

param

proof generated by Base.getTransactionAndWitnessProof

returns

the transaction hashes it commits to

Type declaration

verifyTransactionProof

verifyTransactionProof: (transactionProof: TransactionProof) => Promise<Hash[]>
method

verifyTransactionProof

memberof

DefaultRPC

description

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

param
returns

hash list of transactions committed in the block

Type declaration

Accessors

node

  • Returns Node

paramsFormatter

  • get paramsFormatter(): typeof paramsFormatter
  • Returns typeof paramsFormatter

resultFormatter

  • get resultFormatter(): typeof resultFormatter
  • Returns typeof resultFormatter

rpcProperties

Methods

addMethod

  • Parameters

    Returns void

createBatchRequest

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

    • N: keyof Base

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

    • R

    Parameters

    • Default value params: any = []

    Returns any

getForkBlock

  • method

    getForkBlock

    Parameters

    • blockHash: Hash256

      the fork block hash.

    • Optional verbosity: 2n | "0x2"

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

    Returns Promise<BlockView | null>

    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.

  • Parameters

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

    Returns Promise<SerializedBlock | null>

getRawTxPool

  • method

    getRawTxPool

    memberof

    DefaultRPC

    description

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

    Returns Promise<TxPoolIds>

    CKBComponents.RawTxPool

  • Parameters

    • verbose: true

    Returns Promise<TxPoolVerbosity>

  • Parameters

    • verbose: false | null

    Returns Promise<TxPoolIds>

setNode

  • Parameters

    Returns Node

Generated using TypeDoc