Surfnet::start() (Rust) and Surfnet.start() (JS) boot an offline Surfnet
with transaction-mode block production and a payer pre-funded with 10 SOL. When
you need anything else — a mainnet-forked Surfnet, a slower clock, deterministic
funding, a specific payer keypair — reach for the builder (Rust) or
startWithConfig (JS).
Defaults
If you call start() with no arguments, you get:
Custom Configuration
use surfpool_sdk::{BlockProductionMode, Pubkey, Surfnet};
#[tokio::test(flavor = "multi_thread")]
async fn starts_with_custom_configuration() {
let alice = Pubkey::new_unique();
let surfnet = Surfnet::builder()
.remote_rpc_url("https://api.mainnet.solana.com")
.block_production_mode(BlockProductionMode::Transaction)
.slot_time_ms(10)
.airdrop_addresses(vec![alice])
.airdrop_sol(5_000_000_000)
.skip_blockhash_check(true)
.start()
.await
.unwrap();
assert_eq!(
surfnet.rpc_client().get_balance(&alice).unwrap(),
5_000_000_000
);
}
import { Surfnet } from "@solana/surfpool";
const alice = Surfnet.newKeypair();
const surfnet = Surfnet.startWithConfig({
remoteRpcUrl: "https://api.mainnet.solana.com",
blockProductionMode: "transaction",
slotTimeMs: 10,
airdropAddresses: [alice.publicKey],
airdropSol: 5_000_000_000
});
try {
console.log(surfnet.rpcUrl);
} finally {
surfnet.stop();
}
Builder Reference
The Rust builder and the JS config object expose the same logical options under
camelCase / snake_case naming.
Remote RPC Fallback
Setting remoteRpcUrl (or remote_rpc_url in Rust) flips the Surfnet out of
offline mode. Accounts not present locally are fetched on demand from the
upstream RPC, which is how mainnet-fork tests work.
let surfnet = Surfnet::builder()
.remote_rpc_url("https://api.mainnet.solana.com")
.start()
.await?;
const surfnet = Surfnet.startWithConfig({
remoteRpcUrl: "https://api.mainnet.solana.com"
});
Use a high-quality upstream RPCUse a paid endpoint (Helius, Triton, QuickNode) for tests that exercise many
forked accounts. Public mainnet-beta is heavily rate limited and will flake
under parallel test loads.
Block Production Mode
Custom Payer
By default the payer is a freshly generated keypair. Provide your own when tests
need a known address, for example to pre-build instructions referencing the
payer’s public key.
use surfpool_sdk::{Keypair, Signer, Surfnet};
let payer = Keypair::new();
let surfnet = Surfnet::builder().payer(payer.insecure_clone()).start().await?;
assert_eq!(surfnet.payer().pubkey(), payer.pubkey());
import { Surfnet } from "@solana/surfpool";
const kp = Surfnet.newKeypair();
const surfnet = Surfnet.startWithConfig({
payerSecretKey: kp.secretKey
});
console.assert(surfnet.payer === kp.publicKey);
Feature Gates
Toggle individual SVM feature gates by ID, or activate every known feature with
allFeatures: true (JS only — the Rust builder accepts feature_config for the
full set).
use surfpool_sdk::{Pubkey, Surfnet};
let feature_id: Pubkey = "5cC3foj77CWun58pC51ebHFUWavHWKarWyR5UUik7dnC"
.parse()
.unwrap();
let surfnet = Surfnet::builder()
.enable_feature(feature_id)
.start()
.await?;
const surfnet = Surfnet.startWithConfig({
enableFeatures: ["5cC3foj77CWun58pC51ebHFUWavHWKarWyR5UUik7dnC"],
disableFeatures: ["4a6f7o7iTcA8hRDCrPLkSatnt5Ykxiu36wo5p1Tt12wC"]
});
Skip Blockhash Check
skip_blockhash_check(true) (Rust only) disables blockhash validation on all
transactions. Useful for tests that sign transactions far in advance of
submission or that don’t care about expiry.
Errors
A misconfigured builder fails at start(). The Rust SDK returns SurfnetError:
The JS SDK throws an Error whose message wraps the same underlying variant.