Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@solana/rpc-api

Package Overview
Dependencies
Maintainers
14
Versions
896
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/rpc-api

Defines all default Solana RPC methods as types

  • 2.0.0
  • next
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21K
increased by70.52%
Maintainers
14
Weekly downloads
 
Created
Source

npm npm-downloads
code-style-prettier

@solana/rpc-api

This package contains types that describe the methods of the Solana JSON RPC API, and utilities for creating a RpcApi implementation with sensible defaults. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK @solana/web3.js@rc.

Each RPC method is described in terms of a TypeScript type of the following form:

type ExampleApi = {
    getSomething(address: Address): Something;
};

A RpcApi that implements ExampleApi will ultimately expose its defined methods on any Rpc that uses it.

const rpc: Rpc<ExampleApi> = createExampleRpc(/* ... */);
const something: Something = await rpc.getSomething(address('95DpK3y3GF7U8s1k4EvZ7xqyeCkhsHeZaE97iZpHUGMN')).send();

Types

SolanaRpcApi{Devnet|Testnet|Mainnet}

These types represent the RPC methods available on a specific Solana cluster.

For instance, the test clusters support the RequestAirdropApi while mainnet does not.

Functions

createSolanaRpcApi(config)

Creates a RpcApi implementation of the Solana JSON RPC API with some default behaviours.

The default behaviours include:

  • A transform that converts bigint inputs to number for compatiblity with version 1.0 of the Solana JSON RPC.
  • A transform that calls the config's onIntegerOverflow handler whenever a bigint input would overflow a JavaScript IEEE 754 number. See this GitHub issue for more information.
  • A transform that applies a default commitment wherever not specified
Arguments

A config object with the following properties:

  • defaultCommitment: An optional default Commitment value. Given an RPC method that takes commitment as a parameter, this value will be used when the caller does not supply one.
  • onIntegerOverflow(request, keyPath, value): void: An optional function that will be called whenever a bigint input exceeds that which can be expressed using JavaScript numbers. This is used in the default SolanaRpcApi to throw an exception rather than to allow truncated values to propagate through a program.

Keywords

FAQs

Package last updated on 07 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc