Kit
Functions

isJsonRpcPayload

isJsonRpcPayload(payload): payload is Readonly<{ jsonrpc: "2.0"; method: string; params: unknown }>

Returns true if the given payload is a JSON RPC v2 payload.

This means, the payload is an object such that:

  • It has a jsonrpc property with a value of '2.0'.
  • It has a method property that is a string.
  • It has a params property of any type.

Parameters

ParameterType
payloadunknown

Returns

payload is Readonly<{ jsonrpc: "2.0"; method: string; params: unknown }>

Example

import { isJsonRpcPayload } from '@solana/rpc-spec';
 
if (isJsonRpcPayload(payload)) {
    const payloadMethod: string = payload.method;
    const payloadParams: unknown = payload.params;
}

On this page