Kaspa RPC client

Kaspa RPC client uses wRPC (Workflow RPC) WebSocket interface to connect to directly to Kaspa Node.

Constructors

  • Create a new RPC client with optional [Encoding] and a url.

    Parameters

    Returns RpcClient

    See

    IRpcConfig interface for more details.

Properties

encoding: Encoding

The current protocol encoding.

isConnected: boolean

The current connection status of the RPC client.

nodeId: string

Optional: Beacon node id.

providerName: string

Optional: public node provider name.

providerUrl: string

Optional: public node provider URL.

url: string

The current URL of the RPC client.

Methods

  • Bans a peer from connecting to the Kaspa node for a specified duration. Returned information: None.

    Parameters

    Returns Promise<IBanResponse>

    See

    IBanRequest, IBanResponse

    Throws

    string on an RPC error, a server-side error or when supplying incorrect arguments.

  • Connect to the Kaspa RPC server. This function starts a background task that connects and reconnects to the server if the connection is terminated. Use disconnect() to terminate the connection.

    Parameters

    Returns Promise<void>

    See

    IConnectOptions interface for more details.

  • Disconnect from the Kaspa RPC server.

    Returns Promise<void>

  • Returns void

  • Provides information about the Directed Acyclic Graph (DAG) structure of the Kaspa BlockDAG. Returned information: Number of blocks in the DAG, number of tips in the DAG, hash of the selected parent block, difficulty of the selected parent block, selected parent block blue score, selected parent block time.

    Parameters

    Returns Promise<IGetBlockDagInfoResponse>

    See

    IGetBlockDagInfoRequest, IGetBlockDagInfoResponse

    Throws

    string on an RPC error or a server-side error.

  • Retrieves the current sink block, which is the block with the highest cumulative difficulty in the Kaspa BlockDAG. Returned information: Sink block hash, sink block height.

    Parameters

    Returns Promise<IGetSinkResponse>

    See

    IGetSinkRequest, IGetSinkResponse

    Throws

    string on an RPC error or a server-side error.

  • Tests the connection and responsiveness of a Kaspa node. Returned information: None.

    Parameters

    Returns Promise<IPingResponse>

    See

    IPingRequest, IPingResponse

    Throws

    string on an RPC error or a server-side error.

  • Register a notification callback. IMPORTANT: You are allowed to register only one callback.

    Parameters

    Returns Promise<void>

  • Unregister a notification callback.

    Returns Promise<void>

  • Manage subscription for a block added notification event. Block added notification event is produced when a new block is added to the Kaspa BlockDAG.

    Returns Promise<void>

  • Manage subscription for a virtual DAA score changed notification event. Virtual DAA score changed notification event is produced when the virtual Difficulty Adjustment Algorithm (DAA) score changes in the Kaspa BlockDAG.

    Returns Promise<void>

  • Manage subscription for a finality conflict notification event. Finality conflict notification event is produced when a finality conflict occurs in the Kaspa BlockDAG.

    Returns Promise<void>

  • Manage subscription for a finality conflict resolved notification event. Finality conflict resolved notification event is produced when a finality conflict in the Kaspa BlockDAG is resolved.

    Returns Promise<void>

  • Manage subscription for a new block template notification event. New block template notification event is produced when a new block template is generated for mining in the Kaspa BlockDAG.

    Returns Promise<void>

  • Manage subscription for a pruning point UTXO set override notification event. Pruning point UTXO set override notification event is produced when the UTXO set override for the pruning point changes in the Kaspa BlockDAG.

    Returns Promise<void>

  • Manage subscription for a sink blue score changed notification event. Sink blue score changed notification event is produced when the blue score of the sink block changes in the Kaspa BlockDAG.

    Returns Promise<void>

  • Subscribe for a UTXOs changed notification event. UTXOs changed notification event is produced when the set of unspent transaction outputs (UTXOs) changes in the Kaspa BlockDAG. The event notification will be scoped to the provided list of addresses.

    Parameters

    Returns Promise<void>

  • Manage subscription for a virtual chain changed notification event. Virtual chain changed notification event is produced when the virtual chain changes in the Kaspa BlockDAG.

    Parameters

    • include_accepted_transaction_ids: boolean

    Returns Promise<void>

    • Return copy of self without private attributes.

    Returns Object

  • Return stringified version of self.

    Returns string

  • Unbans a previously banned peer, allowing it to connect to the Kaspa node again. Returned information: None.

    Parameters

    Returns Promise<IUnbanResponse>

    See

    IUnbanRequest, IUnbanResponse

    Throws

    string on an RPC error, a server-side error or when supplying incorrect arguments.

  • Returns Promise<void>

  • Manage subscription for a virtual DAA score changed notification event. Virtual DAA score changed notification event is produced when the virtual Difficulty Adjustment Algorithm (DAA) score changes in the Kaspa BlockDAG.

    Returns Promise<void>

  • Returns Promise<void>

  • Returns Promise<void>

  • Returns Promise<void>

  • Returns Promise<void>

  • Returns Promise<void>

  • Unsubscribe from UTXOs changed notification event for a specific set of addresses.

    Parameters

    Returns Promise<void>

  • Manage subscription for a virtual chain changed notification event. Virtual chain changed notification event is produced when the virtual chain changes in the Kaspa BlockDAG.

    Parameters

    • include_accepted_transaction_ids: boolean

    Returns Promise<void>

  • Parameters

    Returns number

  • Constructs an WebSocket RPC URL given the partial URL or an IP, RPC encoding and a network type.

    Arguments

    • url - Partial URL or an IP address
    • encoding - RPC encoding
    • network_type - Network type

    Parameters

    Returns string

Generated using TypeDoc