Skip to content
@solana/surfpool/kit runs a Surfnet — a local, Solana-compatible network — inside your test process and hands back a Solana Kit client already pointed at it. One .use(surfpool()) replaces the RPC plugin you would normally reach for (solanaLocalRpc(), litesvm()) and adds a pre-funded payer plus Surfpool’s cheatcodes:
No port to pick, no payer to generate and fund, and no separate surfpool start process to manage. New to the SDK? Start with the Overview.

​Which Entry Point You Want

Entry pointReach for it when
surfpool()Default for tests. An isolated Surfnet per test file, with a Kit client already wired up.
surfpool({ rpcUrl })A long-lived surfpool start instance is shared across processes, or your platform has no native binary.
surfnetCheatcodes()You already have a client and only want cheatcodes on it.
Surfnet from @solana/surfpoolYou are not using Kit — see the JS reference.

​Prerequisites

  • Node.js 20.18+, the floor @solana/kit 8 declares. @solana/surfpool itself runs on 18+, but the Kit packages do not. @solana/surfpool 1.7.0 declares a @solana/kit ^8 peer dependency.
  • A supported platform (macOS, Linux x86-64) for embedded mode, which loads a native binary. Elsewhere, use attach mode.
  • Familiarity with Kit’s plugin composition — clients are built by chaining .use() calls, and each plugin adds properties to the client.

​Installation

The Kit packages are declared as optional peer dependencies of @solana/surfpool: skip them if you only use the Surfnet class directly, but importing @solana/surfpool/kit requires @solana/kit and @solana/kit-plugin-rpc. @solana-program/system and @solana-program/token are the program clients the examples below use. See Installation for the platform support matrix and troubleshooting.

​Embedded Mode

Calling surfpool() with no rpcUrl boots an in-process Surfnet on dynamic ports and points the whole Kit client at it. The plugin is async, so await the .use() chain:
Parallel test filesEvery surfpool() call binds its own dynamic ports, so each test file can boot its own isolated Surfnet and the suite still runs in parallel.

​A Complete Test

Boot a Surfnet, send a transfer paid for by the pre-funded payer, and assert on the result. Examples here use node:test; Vitest and Jest work the same way with their own after / afterAll hooks.
transfer.test.ts

​Lifecycle

Call client.surfnet.stop() in teardown, as above, so the Surfnet’s ports and servers are released. stop() is idempotent and synchronous — it returns once the runtime has actually closed. Stopping is final; creating another client boots a fresh instance.
Teardown is not automaticA client held at module scope — the usual pattern for a test file — is never disposed, so nothing stops the Surfnet for you. Without a teardown hook the process can hang or log connection reset warnings as the OS tears down sockets at exit.

​What The Plugin Installs

On the clientComes fromWhat it is
client.payer@solana/kit-plugin-signerA KeyPairSigner for Surfnet’s pre-funded payer account
client.rpc / client.rpcSubscriptions@solana/kit-plugin-rpcThe standard Solana RPC and subscriptions clients, pointed at the Surfnet
client.airdrop@solana/kit-plugin-rpcrequestAirdrop against the Surfnet
client.getMinimumBalance@solana/kit-plugin-rpcRent-exemption lookups
client.transactionPlanner / ...PlanExecutor@solana/kit-plugin-rpcTransaction planning and execution
client.sendTransaction / client.sendTransactions@solana/kit-plugin-rpc (via kit-plugin-instruction-plan)Plan and send instructions in one call
client.rpcUrl / client.wsUrl@solana/surfpool/kitThe Surfnet’s HTTP and WebSocket URLs
client.surfnet@solana/surfpool/kitThe native Surfnet handle (fundSol, deploy, drainEvents, …)
client.cheatcodes@solana/surfpool/kitA typed RPC covering every surfnet_* cheatcode
The plugin does not install an identity. Add one with .use(identity(...)) if your test needs an authority separate from client.payer.

​Cheatcodes

Cheatcodes are state mutations that bypass the normal transaction flow — they run instantly, without consuming a blockhash or paying fees, which is what you want for test setup. client.cheatcodes exposes all of them as a typed RPC. Method names drop the surfnet_ prefix, so surfnet_pauseClock is client.cheatcodes.pauseClock(), and responses arrive already unwrapped from their { context, value } envelope.
The full method list — including streamAccount, cloneProgramAccount, profileTransaction, registerIdl, and resetNetwork — is documented under Cheatcodes and the RPC reference.

​Writing Structured Accounts With A Codec

setAccount takes raw bytes as hex, which pairs well with the account encoders Kit’s program clients ship. Rather than sending transactions to build up state, encode the account you want and write it directly — here, a fully initialized SPL mint with a supply already on it:
The same pattern works for any Codama-generated client: encode with the account’s encoder, hex it, and hand it to setAccount. Pair it with setTokenAccount above to stand up a mint and funded holders without a single transaction.
Cheatcode responses use bigintThe cheatcodes transport parses every JSON integer as a bigint, so u64 values such as rentEpoch survive past 2^53. Request payloads accept number | bigint.

​Cheatcodes Without The Plugin

Two smaller entry points cover cases where you don’t want the full plugin. Both are synchronous — they only attach a transport, so neither needs await.
surfnetCheatcodes() resolves its endpoint from url if given, then from an existing client.rpcUrl (so it composes with any client that carries one), and finally from DEFAULT_SURFNET_ENDPOINT (http://127.0.0.1:8899). Both accept a headers option for authenticating against a remote Surfpool.

​Configuration

Surfnet startup options go under the surfnet key and are forwarded to Surfnet.startWithConfig(). Everything else is forwarded to the local Solana RPC plugin:
Omit surfnet entirely and the plugin calls Surfnet.start() with its defaults. See Configuration for the full set of startup options — remote RPC fallback, block production mode, slot timing, feature gates, and custom payers.

​Composing With Program Plugins

Because surfpool() satisfies the same contracts as solanaLocalRpc(), Kit program plugins layer on top of it and their instructions execute against the embedded Surfnet. Only the final result needs awaiting — use() on an async client returns another async client, so sync and async plugins chain freely.

​Attach Mode

Passing rpcUrl switches the plugin to attach mode: it connects to an already-running Surfpool — one started with surfpool start — instead of booting one. No native module is loaded, so this mode works on platforms without a prebuilt binary. It is also synchronous, so nothing needs awaiting:
Three differences from embedded mode:
  • The client must already have a payer. Attach mode has no access to the running instance’s payer secret key, so it installs none. Fund whichever signer you supply with client.cheatcodes.setAccount(...) or the running instance’s own faucet.
  • There is no client.surfnet handle. In-process helpers are unavailable; use client.cheatcodes for state manipulation instead.
  • surfnet startup config is rejected. The instance is already running, so rpcUrl and surfnet are mutually exclusive in the types.
WebSocket portSurfpool serves subscriptions on its own port (default 8900, --ws-port), independent of the HTTP port. When rpcUrl has an explicit port, the plugin derives the subscriptions URL as port 8900 on the same host. When it has no port — behind a proxy, say — only the protocol is swapped to ws/wss. Set rpcSubscriptionsUrl yourself when neither rule fits.

​Next Steps

  • Programs — deploy your program into the Surfnet before a test
  • Cheatcodes — the full state-mutation surface
  • Configuration — mainnet forking, block production, feature gates
  • Installation — platform support and troubleshooting
  • JS Reference — the Surfnet class behind client.surfnet