npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@solana/kit-plugin-rpc

v0.19.0

Published

RPC support for Kit clients

Downloads

50,164

Readme

Kit Plugins ➤ RPC

npm npm-downloads

This package provides plugins that add RPC functionality to your Kit clients.

Installation

pnpm install @solana/kit-plugin-rpc

solanaRpc plugin

The solanaRpc plugin sets up a full Solana RPC client in a single call. It installs an RPC connection, RPC Subscriptions, minimum balance computation, transaction planning, transaction signing, and transaction execution on the client.

The client must have a payer set before applying this plugin.

Installation

import { createClient } from '@solana/kit';
import { solanaRpc } from '@solana/kit-plugin-rpc';
import { payer } from '@solana/kit-plugin-signer';

const client = createClient()
    .use(payer(myPayer))
    .use(solanaRpc({ rpcUrl: 'https://api.mainnet-beta.solana.com' }));

Options

All options are provided via a SolanaRpcConfig object:

  • rpcUrl (required): URL of the Solana RPC endpoint.
  • rpcSubscriptionsUrl: URL of the RPC Subscriptions endpoint. Defaults to the rpcUrl with the protocol changed from http to ws. As a convenience, the exact strings http://127.0.0.1:8899 and http://localhost:8899 (the canonical local validator RPC endpoints) are rewritten to port 8900. The match is exact-string only — any other host, scheme, or port (including https://localhost:8899 or http://0.0.0.0:8899) is left untouched. Pass rpcSubscriptionsUrl explicitly when your RPC and WebSocket endpoints use different ports.
  • rpcConfig: Optional configuration forwarded to createSolanaRpc.
  • rpcSubscriptionsConfig: Optional configuration forwarded to createSolanaRpcSubscriptions.
  • transactionConfig: Options to configure how transaction messages are created. See the rpcTransactionPlanner options below.
  • maxConcurrency: Maximum number of concurrent transaction executions in the sending executor and transaction preparations in the signing executor. The executors have independent limits. Defaults to 10.
  • skipPreflight: Whether to always skip preflight simulation. Defaults to false.

Features

  • rpc: Call any Solana RPC method.
  • rpcSubscriptions: Subscribe to Solana RPC notifications.
  • getMinimumBalance: Compute minimum lamports for rent exemption.
  • planTransaction(s): Plan instructions into transaction messages without executing them.
  • sendTransaction(s): Plan and execute instructions, instruction plans, or transaction messages in one call.
  • signTransaction(s): Plan and partially sign instructions, instruction plans, or transaction messages in one call.
  • transactionPlanner / transactionPlanExecutor (deprecated): Fields kept for backward compatibility. Use planTransaction(s) / sendTransaction(s) instead.

solanaMainnetRpc plugin

A convenience wrapper around solanaRpc that types the connection as a mainnet URL, preventing accidental use of devnet-only features such as airdrops.

Installation

import { createClient } from '@solana/kit';
import { solanaMainnetRpc } from '@solana/kit-plugin-rpc';
import { payer } from '@solana/kit-plugin-signer';

const client = createClient()
    .use(payer(myPayer))
    .use(solanaMainnetRpc({ rpcUrl: 'https://api.mainnet-beta.solana.com' }));

Features

See solanaRpc for available features.

solanaDevnetRpc plugin

A convenience wrapper around solanaRpc that defaults to the public devnet endpoint (https://api.devnet.solana.com) and includes airdrop support for requesting SOL from the faucet.

Installation

import { createClient } from '@solana/kit';
import { solanaDevnetRpc } from '@solana/kit-plugin-rpc';
import { payerFromFile } from '@solana/kit-plugin-signer';

const client = createClient().use(payerFromFile('~/.config/solana/id.json')).use(solanaDevnetRpc());

Features

See solanaRpc for available features, plus:

  • airdrop: Request SOL from the devnet faucet.
    await client.airdrop(address('HQVxiMVDoV9jzG4tpoxmDZsNfWvaHXm8DGGv93Gka75v'), lamports(1_000_000_000n));

solanaTestnetRpc plugin

A convenience wrapper around solanaRpc that defaults to the public testnet endpoint (https://api.testnet.solana.com) and includes airdrop support for requesting SOL from the faucet.

Installation

import { createClient } from '@solana/kit';
import { solanaTestnetRpc } from '@solana/kit-plugin-rpc';
import { payerFromFile } from '@solana/kit-plugin-signer';

const client = createClient().use(payerFromFile('~/.config/solana/id.json')).use(solanaTestnetRpc());

Features

See solanaRpc for available features, plus:

  • airdrop: Request SOL from the testnet faucet.
    await client.airdrop(address('HQVxiMVDoV9jzG4tpoxmDZsNfWvaHXm8DGGv93Gka75v'), lamports(1_000_000_000n));

solanaLocalRpc plugin

A convenience wrapper around solanaRpc that defaults to http://127.0.0.1:8899 for the RPC and ws://127.0.0.1:8900 for subscriptions, and includes airdrop support.

Installation

import { createClient } from '@solana/kit';
import { solanaLocalRpc } from '@solana/kit-plugin-rpc';
import { payerFromFile } from '@solana/kit-plugin-signer';

const client = createClient().use(payerFromFile('~/.config/solana/id.json')).use(solanaLocalRpc());

Features

See solanaRpc for available features, plus:

  • airdrop: Request SOL from the local validator faucet.
    await client.airdrop(address('HQVxiMVDoV9jzG4tpoxmDZsNfWvaHXm8DGGv93Gka75v'), lamports(1_000_000_000n));

solanaRpcConnection plugin

The solanaRpcConnection plugin creates a Solana RPC and Solana RPC Subscriptions from a cluster URL and installs both on the client.

Installation

import { createClient } from '@solana/kit';
import { solanaRpcConnection } from '@solana/kit-plugin-rpc';

const client = createClient().use(solanaRpcConnection({ rpcUrl: 'https://api.mainnet-beta.solana.com' }));

You may wrap your RPC URL using the mainnet, devnet, or testnet helpers from @solana/kit. When you do, the returned RPC API will be adjusted to match the selected cluster since some RPC features are not available on all clusters.

import { mainnet } from '@solana/kit';

const client = createClient().use(solanaRpcConnection({ rpcUrl: mainnet('https://api.mainnet-beta.solana.com') }));

Options

All options are provided via a SolanaRpcConnectionConfig object:

  • rpcUrl (required): URL of the Solana RPC endpoint.
  • rpcSubscriptionsUrl: URL of the RPC Subscriptions endpoint. Defaults to the rpcUrl with the protocol changed from http to ws. As a convenience, the exact strings http://127.0.0.1:8899 and http://localhost:8899 (the canonical local validator RPC endpoints) are rewritten to port 8900. The match is exact-string only — any other host, scheme, or port (including https://localhost:8899 or http://0.0.0.0:8899) is left untouched. Pass rpcSubscriptionsUrl explicitly when your RPC and WebSocket endpoints use different ports.
  • rpcConfig: Optional configuration forwarded to createSolanaRpc.
  • rpcSubscriptionsConfig: Optional configuration forwarded to createSolanaRpcSubscriptions.

Features

  • rpc: Call any Solana RPC method using type-safe methods.
    const { value: latestBlockhash } = await client.rpc.getLatestBlockhash().send();
  • rpcSubscriptions: Subscribe to Solana RPC notifications using async iterators.
    const slotNotifications = await client.rpcSubscriptions.slotNotifications({ commitment: 'confirmed' }).subscribe();
    for await (const slotNotification of slotNotifications) {
        console.log('Got a slot notification', slotNotification);
    }

rpcAirdrop plugin

This plugin adds an airdrop method to your Kit client that requests SOL airdrops via the RPC and RPC Subscriptions transports.

[!NOTE] Airdrop is only available on test clusters (devnet, testnet) and local validators. Using this plugin with a mainnet RPC will produce a TypeScript error.

Installation

The client must have rpc and rpcSubscriptions installed before applying this plugin.

import { createClient } from '@solana/kit';
import { solanaRpcConnection, rpcAirdrop } from '@solana/kit-plugin-rpc';

const client = createClient()
    .use(solanaRpcConnection({ rpcUrl: 'http://127.0.0.1:8899' }))
    .use(rpcAirdrop());

Features

  • airdrop: An asynchronous helper function that airdrops a specified amount of lamports to a given address.
    await client.airdrop(address('HQVxiMVDoV9jzG4tpoxmDZsNfWvaHXm8DGGv93Gka75v'), lamports(1_000_000_000n));

rpcGetMinimumBalance plugin

This plugin adds a getMinimumBalance method to your Kit client that computes the minimum lamports required for an account with a given data size, using the getMinimumBalanceForRentExemption RPC method.

Installation

The client must have rpc installed before applying this plugin.

import { createClient } from '@solana/kit';
import { solanaRpcConnection, rpcGetMinimumBalance } from '@solana/kit-plugin-rpc';

const client = createClient()
    .use(solanaRpcConnection({ rpcUrl: 'https://api.mainnet-beta.solana.com' }))
    .use(rpcGetMinimumBalance());

Features

  • getMinimumBalance: An asynchronous helper that returns the minimum lamports required for an account with the given data size. By default, the 128-byte account header is included on top of the provided space.

    // Minimum balance for an account with 100 bytes of data (plus header).
    const balance = await client.getMinimumBalance(100);
    
    // Minimum balance for exactly 100 bytes (without adding the header).
    const rawBalance = await client.getMinimumBalance(100, { withoutHeader: true });

rpcTransactionPlanner plugin

Adds planTransaction and planTransactions to the client, using a planner that plans instructions into transaction messages with a fee payer, provisory resource limits (a compute unit limit, plus a loaded accounts data size limit for version 1 transactions), and optional priority fees. The fee payer is read from client.payer lazily, at plan time, so a dynamic payer (such as a connected wallet) is always respected.

Usage

The client must have a payer set before installing the plugin.

import { createClient } from '@solana/kit';
import { rpcTransactionPlanSendingExecutor, rpcTransactionPlanner, solanaRpcConnection } from '@solana/kit-plugin-rpc';
import { generatedPayer } from '@solana/kit-plugin-signer';

const client = await createClient()
    .use(solanaRpcConnection({ rpcUrl: 'https://api.mainnet-beta.solana.com' }))
    .use(generatedPayer())
    .use(rpcTransactionPlanner())
    .use(rpcTransactionPlanSendingExecutor());

const transactionPlan = await client.planTransactions(myInstructionPlan);

Options

All options are provided via a TransactionPlannerConfig object. Its shape is discriminated by the transaction version.

  • For legacy and version 0 transactions:

    • version: The transaction message version to use. Accepts 0 or 'legacy'. Defaults to 0.
    • microLamportsPerComputeUnit: The priority fee in micro-lamports per compute unit, added as a setComputeUnitPrice instruction. Defaults to no priority fees.
    • estimateResourceLimits: Whether to estimate and set resource limits by simulating before signing or sending. Set to false to skip estimation and reserve no provisory limits, which is useful for transactions close to the message size limit. Defaults to true.
  • For version 1 transactions:

    • version: Set to 1 to create version 1 transaction messages.
    • priorityFeeLamports: The total priority fee in lamports, written to the version 1 resource header. Defaults to no priority fees.
    • estimateResourceLimits: Whether to estimate and set resource limits by simulating before signing or sending. For version 1 transactions, estimation covers both the compute unit limit and the loaded accounts data size limit. Defaults to true.

rpcTransactionPlanSendingExecutor plugin

Adds sendTransaction and sendTransactions to the client, using an executor that estimates resource limits, signs, and sends transactions via RPC. Resource limit estimation covers the compute unit limit and, for version 1 transactions, the loaded accounts data size limit.

Usage

The client must have rpc and rpcSubscriptions configured, and a transaction planner installed, before installing this plugin — sending plans through the client's planning functions.

import { createClient } from '@solana/kit';
import { rpcTransactionPlanSendingExecutor, rpcTransactionPlanner, solanaRpcConnection } from '@solana/kit-plugin-rpc';
import { generatedPayer } from '@solana/kit-plugin-signer';

const client = await createClient()
    .use(solanaRpcConnection({ rpcUrl: 'https://api.mainnet-beta.solana.com' }))
    .use(generatedPayer())
    .use(rpcTransactionPlanner())
    .use(rpcTransactionPlanSendingExecutor());

const transactionPlanResult = await client.sendTransactions(myInstructionPlan);

Options

All options are provided via a RpcTransactionPlanExecutorConfig object:

  • estimateResourceLimits: Whether to estimate and set resource limits by simulating before sending (default: true). This should match the estimateResourceLimits option on the planner; solanaRpc keeps them in sync automatically.
  • getComputeUnitLimitFromEstimate: A (estimatedComputeUnits: number) => number function that maps the estimated compute unit consumption to the compute unit limit to set, adding headroom for variation between simulation and execution. Defaults to a function that adds a buffer on top of the estimate of at least 300 compute units, or a margin that decays linearly from 10% at low estimates to 2% at 500,000 compute units and above, whichever is greater. The result is always capped at 1,400,000 (the per-transaction maximum).
  • maxConcurrency: Maximum number of concurrent executions (default: 10).
  • skipPreflight: Whether to skip the preflight simulation when sending transactions (default: false).

Result context

As it works through a transaction, the executor records the planned message (once its blockhash lifetime and resource limits are set), the fully signed transaction, and the signature it was sent under. A successful plan result carries all three on its context, and the exported RpcSendContext type names that shape so you can annotate results yourself.

import { SuccessfulSingleTransactionPlanResult } from '@solana/kit';
import { RpcSendContext } from '@solana/kit-plugin-rpc';

function logSentTransaction(result: SuccessfulSingleTransactionPlanResult<RpcSendContext>) {
    console.log(
        `Sent ${result.context.signature} using blockhash ${result.context.message.lifetimeConstraint.blockhash}`,
    );
}

Because the context is filled in as execution progresses, a transaction that fails or is canceled part way through carries only what was recorded before it stopped. Failed and canceled results therefore type the context as partial — only successful results guarantee every field.

The sendTransaction and sendTransactions functions installed by this plugin propagate this context type, so their results carry a typed RpcSendContext without any annotation needed.

Preflight and Resource Limit Estimation

By default, the executor estimates resource limits by simulating the transaction before sending it. This covers the compute unit limit and, for version 1 transactions, the loaded accounts data size limit. When estimation is performed, preflight is skipped to avoid a redundant second simulation. When every applicable resource limit is already explicitly set (no estimation needed), preflight runs as the only simulation.

Setting skipPreflight: true changes the behavior:

  • Preflight is always skipped regardless of whether estimation was performed.
  • If the resource limit estimation simulation fails, the consumed resources from the failed simulation are used to set the limits (with the compute unit buffer from getComputeUnitLimitFromEstimate applied) so the transaction still reaches the validator. This is useful for debugging failed transactions in an explorer.

| Scenario | skipPreflight: false (default) | skipPreflight: true | | ------------------- | -------------------------------- | -------------------------------------- | | Estimation succeeds | Set limits, skip preflight | Set limits, skip preflight | | Estimation fails | Throw | Use consumed resources, skip preflight | | Explicit limits set | Run preflight | Skip preflight |

Set estimateResourceLimits: false to opt out of resource limit estimation entirely. The planner then reserves no provisory resource limits and the executor does not simulate to estimate or inject any; any explicit resource limits already present on the message are preserved. This is useful for transactions close to the message size limit, where adding a compute budget instruction would make an otherwise valid transaction too large.

Note that disabling estimation does not disable preflight. When estimateResourceLimits: false and skipPreflight is left at its default false, the executor still runs a preflight simulation when sending — this becomes the only simulation. To avoid all simulation overhead, set skipPreflight: true as well.

When using solanaRpc, both the planner and executor read estimateResourceLimits from a single place: transactionConfig.

const client = createClient()
    .use(payer(myPayer))
    .use(
        solanaRpc({
            rpcUrl: 'https://api.mainnet-beta.solana.com',
            skipPreflight: true,
            transactionConfig: { estimateResourceLimits: false },
        }),
    );

Compute unit buffer

Because a transaction can consume slightly more compute units at execution time than during simulation, the executor adds a buffer to the estimated compute unit limit. By default this buffer is the greater of a fixed minimum of 300 compute units and a margin that decays linearly from 10% at low estimates to 2% at 500,000 compute units and above, added on top of the estimate.

Override this by passing a getComputeUnitLimitFromEstimate function that maps the raw estimate to the limit to set. It is applied on both successful estimation and the skipPreflight recovery path. The resulting limit is always capped at 1,400,000, the maximum number of compute units allowed per transaction, including for custom functions.

const client = createClient()
    .use(payer(myPayer))
    .use(
        solanaRpc({
            rpcUrl: 'https://api.mainnet-beta.solana.com',
            // Add a flat 20% buffer instead of the default curve.
            getComputeUnitLimitFromEstimate: estimatedComputeUnits => Math.ceil(estimatedComputeUnits * 1.2),
        }),
    );

rpcTransactionPlanSigningExecutor plugin

Adds signTransaction and signTransactions to the client, using an executor that sets a blockhash, estimates resource limits, and applies every available transaction signer without requiring the transaction to be fully signed.

Usage

The client must have rpc configured and a transaction planner installed before installing this plugin.

import { createClient } from '@solana/kit';
import { rpcTransactionPlanSigningExecutor, rpcTransactionPlanner, solanaRpcConnection } from '@solana/kit-plugin-rpc';
import { generatedPayer } from '@solana/kit-plugin-signer';

const client = await createClient()
    .use(solanaRpcConnection({ rpcUrl: 'https://api.mainnet-beta.solana.com' }))
    .use(generatedPayer())
    .use(rpcTransactionPlanner())
    .use(rpcTransactionPlanSigningExecutor());

const transactionPlanResult = await client.signTransactions(myInstructionPlan);

solanaRpc installs this plugin automatically alongside the sending executor.

Before signing, the executor replaces any lifetime already set on an input transaction message with a fresh blockhash lifetime. A transaction-modifying signer may replace the transaction lifetime during signing, but a durable nonce set directly on the input message is not preserved.

Options

All options are provided via a RpcTransactionPlanSigningExecutorConfig object:

  • estimateResourceLimits: Whether to estimate and set resource limits by simulating before signing (default: true). This should match the estimateResourceLimits option on the planner; solanaRpc keeps them in sync automatically.
  • getComputeUnitLimitFromEstimate: A (estimatedComputeUnits: number) => number function that maps estimated compute unit consumption to the limit to set. It uses the same default buffer and 1.4M-unit cap as the sending executor.
  • maxConcurrency: Maximum number of transactions prepared and signed concurrently across all calls to this installed signing executor (default: 10). This bounds resource limit simulations and signer requests together, and is independent from the sending executor.

Result context

A successful transaction result carries the prepared message, the partially or fully signed transaction, and its Base64-encoded wire representation in its context. The exported RpcSignContext type describes this shape. Its signature is optional because it is only available when the fee payer signed.

const result = await client.signTransaction(myInstructionPlan);

result.context.message;
result.context.transaction;
result.context.transactionBase64;
if (result.context.signature) {
    console.log(`Transaction signature: ${result.context.signature}`);
}

The executor queues every transaction plan leaf without waiting for sequential execution constraints, then prepares and signs up to maxConcurrency transactions at a time. The returned result still preserves the original plan's nesting, order, and divisibility. If one transaction fails to sign, the executor still attempts every other transaction and includes all outcomes in the signing error's transaction plan result.

Sequential dependencies

The signing executor prepares and simulates transaction plan leaves independently, up to maxConcurrency at a time. It does not execute earlier transactions, so resource limit estimation can fail when a transaction depends on account or state changes produced by an earlier transaction in a sequential plan.

Use sendTransactions when those dependencies must execute in order. When only signing is needed and simulation is unsuitable, set estimateResourceLimits: false on both the planner and signing executor and provide explicit resource limits where needed.

const client = await createClient()
    .use(solanaRpcConnection({ rpcUrl: 'https://api.mainnet-beta.solana.com' }))
    .use(generatedPayer())
    .use(rpcTransactionPlanner({ estimateResourceLimits: false }))
    .use(rpcTransactionPlanSigningExecutor({ estimateResourceLimits: false }));

With solanaRpc, set transactionConfig.estimateResourceLimits to false to configure both.

Deprecated plugins

The following plugins are still exported for backward compatibility but are deprecated. Prefer solanaRpcConnection for new code.

  • rpcConnection(rpc) / rpcSubscriptionsConnection(rpcSubscriptions): Trivial wrappers around extendClient. Inline extendClient({ rpc }) or extendClient({ rpcSubscriptions }) instead, or use solanaRpcConnection when starting from a cluster URL.

  • solanaRpcSubscriptionsConnection(url, config?): No longer needed because solanaRpcConnection installs both rpc and rpcSubscriptions.

  • rpcTransactionPlanExecutor(config?): Only sets the deprecated client.transactionPlanExecutor field. Use rpcTransactionPlanSendingExecutor instead, which installs sendTransaction and sendTransactions alongside the executor.

    // Before
    const client = await createClient()
        .use(rpcTransactionPlanner())
        .use(rpcTransactionPlanExecutor())
        .use(planAndSendTransactions());
    
    // After
    const client = await createClient().use(rpcTransactionPlanner()).use(rpcTransactionPlanSendingExecutor());