Skip to content

Latest commit

 

History

History
116 lines (71 loc) · 7.52 KB

File metadata and controls

116 lines (71 loc) · 7.52 KB

RPC

Provides access to the exported methods of RPC Client and data structures where serialized response.

The RpcClient implements RPC methods according to spec. RpcClient unites implementation of ClientInformational interface related to spec and ClientPOS interface related to spec.

Usage

The configuration is flexible, and caller can provide custom configurations, the most common usage is to create RpcClient which depends on HttpHandler interface.

import { HttpHandler, RpcClient } from 'casper-js-sdk';

const rpcHandler = new HttpHandler('http://<Node Address>:7777/rpc');
const rpcCient = new RpcClient(rpcHandler);

Methods

The RpcClient combines the functionalities of ClientPOS, ClientInformational, and ClientTransactional.

The ClientPOS interface includes methods related to the Proof-of-Stake functionality of the Casper network.

  • getAuctionInfoByHash(blockHash: string) -Retrieves auction information for a specific block by hash.
    Returns: StateGetAuctionInfoResult
  • getAuctionInfoByHeight(height: number) - Retrieves auction information for a specific block by height.
    Returns: StateGetAuctionInfoResult
  • getEraInfoByBlockHeight(height: number) - Fetches era information for a specific block by height.
    Returns: ChainGetEraInfoResult
  • getEraInfoByBlockHash(hash: string) - Fetches era information for a specific block by hash.
    Returns: ChainGetEraInfoResult

The ClientInformational interface provides methods for querying node-specific and network-wide information.

Balance Queries

  • getLatestBalance(purseURef: string) - Retrieves the latest balance for a given purse.
    Returns: StateGetBalanceResult
  • getBalanceByStateRootHash(purseURef: string, stateRootHash: string) - Retrieves the balance for a specific state root hash.
    Returns: StateGetBalanceResult

Deploy Queries

  • getDeployFinalizedApproval(hash: string) - Retrieves a deploy with finalized approvals.
    Returns: InfoGetDeployResult

Transaction Queries

  • getTransactionByTransactionHash(transactionHash: string) - Retrieves a transaction by its hash.
    Returns: InfoGetTransactionResult
  • getTransactionByDeployHash(deployHash: string) - Retrieves a transaction by its deploy hash.
    Returns: InfoGetTransactionResult

Dictionary Queries

  • getDictionaryItem(stateRootHash: string | null, uref: string, key: string) - Retrieves an item from a dictionary.
    Returns: StateGetDictionaryResult
  • getDictionaryItemByIdentifier(stateRootHash: string | null, identifier: ParamDictionaryIdentifier) - Retrieves an item using a dictionary identifier.
    Returns: StateGetDictionaryResult

Global State Queries

  • queryLatestGlobalState(key: string, path: string[]) - Queries the latest global state.
    Returns: QueryGlobalStateResult

Account Queries

  • getAccountInfoByBlockHash(blockHash: string, pub: PublicKey) - Retrieves account information using a block hash.
    Returns: StateGetAccountInfo

Block Queries

Era Summary Queries

Status and Peers

The ClientTransactional interface provides methods for deploying transactions to the network.

  • putDeploy(deploy: Deploy) - Sends a deploy to the network.
    Returns: PutDeployResult
  • putTransactionV1(transaction: TransactionV1) - Sends a transaction (v1) to the network.
    Returns: PutTransactionResult