Class JsonRpcProvider

Extends the main provider class in near-api-js, adding more methods for interacting with an endpoint.

Hierarchy

Constructors

  • Parameters

    • connectionInfo: ConnectionInfo

      Connection info

    Returns JsonRpcProvider

Properties

providers: Map<string, JsonRpcProvider> = ...

Methods

  • Gets account changes for a given array of accountIds pass block_id OR finality as blockQuery, not both See docs for more info

    Parameters

    Returns Promise<ChangeResult>

  • Parameters

    • accountId: string
    • Optional blockQuery: {
          block_id: BlockId;
      } | {
          finality: Finality;
      }

    Returns Promise<boolean>

  • Gets contract code changes for a given array of accountIds pass block_id OR finality as blockQuery, not both Note: Change is returned in a base64 encoded WASM file See docs for more info

    Parameters

    Returns Promise<ChangeResult>

  • Gets contract state changes for a given array of accountIds pass block_id OR finality as blockQuery, not both Note: If you pass a keyPrefix it must be base64 encoded See docs for more info

    Parameters

    • accountIdArray: string[]
    • blockQuery: BlockReference
    • Optional keyPrefix: string

    Returns Promise<ChangeResult>

  • Fast forward to a point in the future. The delta block height is supplied to tell the network to advanced a certain amount of blocks. This comes with the advantage only having to wait a fraction of the time it takes to produce the same number of blocks.

    Estimate as to how long it takes: if our delta_height crosses X epochs, then it would roughly take X * 5 milliseconds for the fast forward request to be processed.

    Note: This is not to be confused with speeding up the current in-flight transactions; the state being forwarded in this case refers to time-related state (the block height, timestamp and epoch).

    Parameters

    • deltaHeight: number

    Returns Promise<Empty>

    Promise

  • Query the RPC by passing an "@near-js/types".provider/request.RpcQueryRequest | RpcQueryRequest

    Type Parameters

    Parameters

    • Rest ...args: any[]

    Returns Promise<T>

  • Directly call the RPC specifying the method and params

    Type Parameters

    • T

    Parameters

    • method: string

      RPC method

    • params: object

      Parameters to the method

    Returns Promise<T>

  • Gets a transaction's status from the RPC with receipts See docs for more info

    Parameters

    • txHash: string | Uint8Array

      The hash of the transaction

    • accountId: string

      The NEAR account that signed the transaction

    Returns Promise<FinalExecutionOutcome>

  • Get full response from RPC about result of view method

    Parameters

    • accountId: string
    • methodName: string
    • args: string

      Base64 encoded string

    • blockQuery: {
          block_id: BlockId;
      } | {
          finality: Finality;
      } = OPTIMISTIC

    Returns Promise<CodeResult>

  • Download the binary of a given contract.

    Parameters

    • accountId: string

      contract account

    • Optional blockQuery: {
          block_id: BlockId;
      } | {
          finality: Finality;
      }

    Returns Promise<Buffer>

    Buffer of Wasm binary

  • Download the binary of a given contract.

    Parameters

    • accountId: string

      contract account

    • blockQuery: {
          block_id: BlockId;
      } | {
          finality: Finality;
      } = OPTIMISTIC

    Returns Promise<string>

    Base64 string of Wasm binary

  • Download the state of a contract given a prefix of a key.

    Parameters

    • accountId: string

      contract account to lookup

    • prefix: string | Uint8Array

      string or byte prefix of keys to loodup

    • Optional blockQuery: {
          block_id: BlockId;
      } | {
          finality: Finality;
      }

      state at what block, defaults to most recent final block

    Returns Promise<{
        key: Buffer;
        value: Buffer;
    }[]>

    raw RPC response

  • Download the state of a contract given a prefix of a key without decoding from base64.

    Parameters

    • accountId: string

      contract account to lookup

    • prefix: string | Uint8Array

      string or byte prefix of keys to loodup

    • Optional blockQuery: {
          block_id: BlockId;
      } | {
          finality: Finality;
      }

      state at what block, defaults to most recent final block

    Returns Promise<StateItem[]>

    raw RPC response

Generated using TypeDoc