Skip to content
Cheatcodes are state mutations that bypass the normal transaction flow. They run instantly without consuming a blockhash or paying fees, which is exactly what you want for test setup. In Rust, cheatcodes live under Surfnet::cheatcodes(). In JS, they’re methods directly on the Surfnet instance.

​Fund SOL

fundSol / fund_sol sets the lamport balance on any account, creating the account if it doesn’t exist.

​Fund Tokens

fundToken / fund_token mints tokens to a wallet by computing the associated token account, creating it if needed, and setting the amount. The mint itself must exist on the Surfnet, or reading the balance fails with Account <mint> not found. The examples below fund mainnet mints (USDC and PYUSD), so they start the Surfnet with remoteRpcUrl (remote_rpc_url in Rust) to fetch the mints on demand. On an offline Surfnet, create the mint first.
Token-2022 mintsBy default fundToken uses the classic SPL Token program. For Token-2022 mints, pass the Token-2022 program ID (TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb) as the final argument. The program must match the mint’s owner.
To derive the ATA without funding, use getAta / get_ata:

​Set Arbitrary Account State

The setAccount method writes lamports, owner, and raw data bytes for any account in one call. The Rust SDK additionally exposes a SetAccount builder for more advanced fields like rent_epoch and executable.

​Mutate Token Account Fields

setTokenAccount updates the advanced fields of an existing token account — delegate, state, close authority, delegated amount. Use it when fundToken alone isn’t enough.

​Reset Accounts To Upstream State

resetAccount discards any local mutations and re-fetches the account from the upstream RPC. Pass includeOwnedAccounts: true to also reset every account owned by the target — useful when resetting a program and all of its PDAs.
Needs `remoteRpcUrl` to re-fetchOn an offline Surfnet, resetAccount clears the local copy but has no upstream to fetch from. Configure remoteRpcUrl at startup to make resets restore upstream state.

​Stream Live Accounts

streamAccount registers an account for background polling from the upstream RPC. The local Surfnet copy stays in sync with mainnet without the test having to poll explicitly. Combine with includeOwnedAccounts to stream every PDA owned by a program.
Requires `remoteRpcUrl`streamAccount only works on a Surfnet started with remoteRpcUrl (or remote_rpc_url in Rust). Without an upstream RPC there is nothing to stream from: the call returns normally and does nothing.

​Cheatcode Builders (Rust)

The Rust SDK exposes typed builders under surfpool_sdk::cheatcodes::builders for cases where the convenience methods aren’t enough. Every builder implements the CheatcodeBuilder trait and is executed via cheats.execute(builder).
BuilderConstructorCommon setters
SetAccountnew(address: Pubkey)lamports, data, owner, rent_epoch, executable
SetTokenAccountnew(owner: Pubkey, mint: Pubkey)amount, delegate, clear_delegate, state, delegated_amount, close_authority, clear_close_authority, token_program
ResetAccountnew(address: Pubkey)include_owned_accounts(bool)
StreamAccountnew(address: Pubkey)include_owned_accounts(bool)
DeployProgramnew(program_id: Pubkey), from_keypair_path(path)so_path, so_bytes, idl_path
For the full JS surface, see JS Reference. For the full Rust surface, see Rust Reference.