Skip to main content

SurfnetCheatcodes

Trait SurfnetCheatcodes 

Source
pub trait SurfnetCheatcodes:
    Sized
    + Send
    + Sync
    + 'static {
    type Metadata: Metadata;

Show 27 methods // Required methods fn set_account( &self, meta: Self::Metadata, pubkey: String, update: AccountUpdate, ) -> BoxFuture<Result<RpcResponse<()>>>; fn enable_cheatcode( &self, meta: Self::Metadata, cheatcodes_filter: CheatcodeFilter, ) -> Result<RpcResponse<()>>; fn disable_cheatcode( &self, meta: Self::Metadata, cheatcodes_filter: CheatcodeFilter, lockout: Option<CheatcodeControlConfig>, ) -> Result<RpcResponse<()>>; fn set_token_account( &self, meta: Self::Metadata, owner: String, mint: String, update: TokenAccountUpdate, token_program: Option<String>, ) -> BoxFuture<Result<RpcResponse<()>>>; fn clone_program_account( &self, meta: Self::Metadata, source_program_id: String, destination_program_id: String, ) -> BoxFuture<Result<RpcResponse<()>>>; fn profile_transaction( &self, meta: Self::Metadata, transaction_data: String, tag: Option<String>, config: Option<RpcProfileResultConfig>, ) -> BoxFuture<Result<RpcResponse<UiKeyedProfileResult>>>; fn get_profile_results_by_tag( &self, meta: Self::Metadata, tag: String, config: Option<RpcProfileResultConfig>, ) -> Result<RpcResponse<Option<Vec<UiKeyedProfileResult>>>>; fn set_supply( &self, meta: Self::Metadata, update: SupplyUpdate, ) -> BoxFuture<Result<RpcResponse<()>>>; fn set_program_authority( &self, meta: Self::Metadata, program_id_str: String, new_authority_str: Option<String>, ) -> BoxFuture<Result<RpcResponse<()>>>; fn get_transaction_profile( &self, meta: Self::Metadata, signature_or_uuid: UuidOrSignature, config: Option<RpcProfileResultConfig>, ) -> Result<RpcResponse<Option<UiKeyedProfileResult>>>; fn register_idl( &self, meta: Self::Metadata, idl: Idl, slot: Option<Slot>, ) -> Result<RpcResponse<()>>; fn get_idl( &self, meta: Self::Metadata, program_id: String, slot: Option<Slot>, ) -> Result<RpcResponse<Option<Idl>>>; fn get_local_signatures( &self, meta: Self::Metadata, limit: Option<u64>, ) -> BoxFuture<Result<RpcResponse<Vec<RpcLogsResponse>>>>; fn time_travel( &self, meta: Self::Metadata, config: Option<TimeTravelConfig>, ) -> Result<EpochInfo>; fn pause_clock(&self, meta: Self::Metadata) -> Result<EpochInfo>; fn resume_clock(&self, meta: Self::Metadata) -> Result<EpochInfo>; fn reset_account( &self, meta: Self::Metadata, pubkey_str: String, config: Option<ResetAccountConfig>, ) -> Result<RpcResponse<()>>; fn reset_network( &self, meta: Self::Metadata, ) -> BoxFuture<Result<RpcResponse<()>>>; fn offline_account( &self, meta: Self::Metadata, pubkey_str: String, config: Option<OfflineAccountConfig>, ) -> BoxFuture<Result<RpcResponse<()>>>; fn export_snapshot( &self, meta: Self::Metadata, config: Option<ExportSnapshotConfig>, ) -> Result<RpcResponse<BTreeMap<String, AccountSnapshot>>>; fn stream_account( &self, meta: Self::Metadata, pubkey_str: String, config: Option<StreamAccountConfig>, ) -> Result<RpcResponse<()>>; fn stream_accounts( &self, meta: Self::Metadata, accounts: Vec<StreamAccountsEntry>, ) -> Result<RpcResponse<()>>; fn get_streamed_accounts( &self, meta: Self::Metadata, ) -> Result<RpcResponse<GetStreamedAccountsResponse>>; fn get_surfnet_info( &self, meta: Self::Metadata, ) -> Result<RpcResponse<GetSurfnetInfoResponse>>; fn write_program( &self, meta: Self::Metadata, program_id: String, data: String, offset: usize, authority: Option<String>, ) -> BoxFuture<Result<RpcResponse<()>>>; fn register_scenario( &self, meta: Self::Metadata, scenario: Scenario, slot: Option<Slot>, ) -> Result<RpcResponse<()>>; // Provided method fn to_delegate(self) -> IoDelegate<Self, Self::Metadata> { ... }
}

Required Associated Types§

Required Methods§

Source

fn set_account( &self, meta: Self::Metadata, pubkey: String, update: AccountUpdate, ) -> BoxFuture<Result<RpcResponse<()>>>

A “cheat code” method for developers to set or update an account in Surfpool.

This method allows developers to set or update the lamports, data, owner, executable status, and rent epoch of a given account.

§Parameters
  • pubkey: The public key of the account to be updated, as a base-58 encoded string.
  • update: The AccountUpdate struct containing the fields to update the account.
§Returns

A RpcResponse<()> indicating whether the account update was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_setAccount",
  "params": ["account_pubkey", {"lamports": 1000, "data": "base58string", "owner": "program_pubkey"}]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
§Notes

This method is designed to help developers set or modify account properties within Surfpool. Developers can quickly test or update account attributes, such as lamports, program ownership, and executable status.

§See Also
  • getAccount, getAccountInfo, getAccountBalance
Source

fn enable_cheatcode( &self, meta: Self::Metadata, cheatcodes_filter: CheatcodeFilter, ) -> Result<RpcResponse<()>>

Enables one or more Surfpool cheatcode RPC methods for the current session.

This method allows developers to re-enable cheatcode methods that were previously disabled. Each cheatcode name must match a valid surfnet_* RPC method (e.g. surfnet_setAccount, surfnet_timeTravel).

§Parameters
  • cheatcodes: A list of cheatcode method names to enable, as strings (e.g. ["surfnet_setAccount", "surfnet_timeTravel"]).
§Returns

A RpcResponse<()> indicating whether the enable operation was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_enableCheatcode",
  "params": [["surfnet_setAccount", "surfnet_timeTravel"]]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
§Notes

Invalid cheatcode names return an error. Use surfnet_disableCheatcode to disable methods and surfnet_lockout to allow disabling surfnet_enableCheatcode and surfnet_disableCheatcode themselves.

§See Also
  • surfnet_disableCheatcode, surfnet_disableAllCheatcodes, surfnet_lockout
Source

fn disable_cheatcode( &self, meta: Self::Metadata, cheatcodes_filter: CheatcodeFilter, lockout: Option<CheatcodeControlConfig>, ) -> Result<RpcResponse<()>>

Disables one or more Surfpool cheatcode RPC methods for the current session.

This method allows developers to turn off specific cheatcode methods so they are no longer callable. Each cheatcode name must match a valid surfnet_* RPC method. When lockout is not enabled, surfnet_enableCheatcode and surfnet_disableCheatcode cannot be disabled.

§Parameters
  • cheatcodes: A list of cheatcode method names to disable, as strings (e.g. ["surfnet_setAccount"]).
§Returns

A RpcResponse<()> indicating whether the disable operation was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_disableCheatcode",
  "params": [["surfnet_setAccount", "surfnet_timeTravel"]]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
§Notes

Call surfnet_lockout first if you need to disable surfnet_enableCheatcode or surfnet_disableCheatcode.

§See Also
  • surfnet_enableCheatcode, surfnet_disableAllCheatcodes, surfnet_lockout
Source

fn set_token_account( &self, meta: Self::Metadata, owner: String, mint: String, update: TokenAccountUpdate, token_program: Option<String>, ) -> BoxFuture<Result<RpcResponse<()>>>

A “cheat code” method for developers to set or update a token account in Surfpool.

This method allows developers to set or update various properties of a token account, including the token amount, delegate, state, delegated amount, and close authority.

§Parameters
  • owner: The base-58 encoded public key of the token account’s owner.
  • mint: The base-58 encoded public key of the token mint (e.g., the token type).
  • update: The TokenAccountUpdate struct containing the fields to update the token account.
  • token_program: The optional base-58 encoded address of the token program (defaults to the system token program).
§Returns

A RpcResponse<()> indicating whether the token account update was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_setTokenAccount",
  "params": ["owner_pubkey", "mint_pubkey", {"amount": 1000, "state": "initialized"}]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
§Notes

This method is designed to help developers quickly test or modify token account properties in Surfpool. Developers can update attributes such as token amounts, delegates, and authorities for specific token accounts.

§See Also
  • getTokenAccountInfo, getTokenAccountBalance, getTokenAccountDelegate
Source

fn clone_program_account( &self, meta: Self::Metadata, source_program_id: String, destination_program_id: String, ) -> BoxFuture<Result<RpcResponse<()>>>

Source

fn profile_transaction( &self, meta: Self::Metadata, transaction_data: String, tag: Option<String>, config: Option<RpcProfileResultConfig>, ) -> BoxFuture<Result<RpcResponse<UiKeyedProfileResult>>>

Estimates the compute units that a given transaction will consume.

This method simulates the transaction without committing its state changes and returns an estimation of the compute units used, along with logs and potential errors.

§Parameters
  • transaction_data: A base64 encoded string of the VersionedTransaction.
  • tag: An optional tag for the transaction.
  • encoding: An optional encoding for returned account data.
§Returns

A RpcResponse<ProfileResult> containing the estimation details and a snapshot of the accounts before and after execution.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_profileTransaction",
  "params": ["base64_encoded_transaction_string", "optional_tag"]
}
Source

fn get_profile_results_by_tag( &self, meta: Self::Metadata, tag: String, config: Option<RpcProfileResultConfig>, ) -> Result<RpcResponse<Option<Vec<UiKeyedProfileResult>>>>

Retrieves all profiling results for a given tag.

§Parameters
  • tag: The tag to retrieve profiling results for.
§Returns

A RpcResponse<Vec<ProfileResult>> containing the profiling results.

Source

fn set_supply( &self, meta: Self::Metadata, update: SupplyUpdate, ) -> BoxFuture<Result<RpcResponse<()>>>

A “cheat code” method for developers to set or update the network supply information in Surfpool.

This method allows developers to configure the total supply, circulating supply, non-circulating supply, and non-circulating accounts list that will be returned by the getSupply RPC method.

§Parameters
  • update: The SupplyUpdate struct containing the optional fields to update:
    • total: Optional total supply in lamports
    • circulating: Optional circulating supply in lamports
    • non_circulating: Optional non-circulating supply in lamports
    • non_circulating_accounts: Optional list of non-circulating account addresses
§Returns

A RpcResponse<()> indicating whether the supply update was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_setSupply",
  "params": [{
    "total": 1000000000000000,
    "circulating": 800000000000000,
    "non_circulating": 200000000000000,
    "non_circulating_accounts": ["Account1...", "Account2..."]
  }]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
§Notes

This method is designed to help developers test supply-related functionality by allowing them to configure the values returned by getSupply without needing to connect to a real network or manipulate actual token supplies.

§See Also
  • getSupply
Source

fn set_program_authority( &self, meta: Self::Metadata, program_id_str: String, new_authority_str: Option<String>, ) -> BoxFuture<Result<RpcResponse<()>>>

A cheat code to set the upgrade authority of a program’s ProgramData account.

This method allows developers to directly patch the upgrade authority of a program’s ProgramData account.

§Parameters
  • program_id: The base-58 encoded public key of the program.
  • new_authority: The base-58 encoded public key of the new authority. If omitted, the program will have no upgrade authority.
§Returns

A RpcResponse<()> indicating whether the authority update was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_setProgramAuthority",
  "params": [
    "PROGRAM_ID_BASE58",
    "NEW_AUTHORITY_BASE58"
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
Source

fn get_transaction_profile( &self, meta: Self::Metadata, signature_or_uuid: UuidOrSignature, config: Option<RpcProfileResultConfig>, ) -> Result<RpcResponse<Option<UiKeyedProfileResult>>>

A cheat code to get the transaction profile for a given signature or UUID.

§Parameters
  • signature_or_uuid: The transaction signature (as a base-58 string) or a UUID (as a string) for which to retrieve the profile.
§Returns

A RpcResponse<Option<ProfileResult>> containing the transaction profile if found, or None if not found.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_getTransactionProfile",
  "params": [
    "5Nf3...TxSignatureOrUuidHere"
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "context": {
    "slot": 355684457,
    "apiVersion": "2.2.2"
  },
  "value": { /* ...ProfileResult object... */ },
  "id": 1
}
Source

fn register_idl( &self, meta: Self::Metadata, idl: Idl, slot: Option<Slot>, ) -> Result<RpcResponse<()>>

A cheat code to register an IDL for a given program in memory.

§Parameters
  • idl: The full IDL object to be registered in memory. The address field should match the program’s public key.
  • slot (optional): The slot at which to register the IDL. If omitted, uses the latest slot.
§Returns

A RpcResponse<()> indicating whether the IDL registration was successful.

§Example Request (with slot)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_registerIdl",
  "params": [
    {
      "address": "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa",
      "metadata": {
        "name": "test",
        "version": "0.1.0",
        "spec": "0.1.0",
        "description": "Created with Anchor"
      },
      "instructions": [
        {
          "name": "initialize",
          "discriminator": [175,175,109,31,13,152,155,237],
          "accounts": [],
          "args": []
        }
      ],
      "accounts": [],
      "types": [],
      "events": [],
      "errors": [],
      "constants": [],
      "state": null
    },
    355684457
  ]
}
§Example Request (without slot)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_registerIdl",
  "params": [
    {
      "address": "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa",
      "metadata": {
        "name": "test",
        "version": "0.1.0",
        "spec": "0.1.0",
        "description": "Created with Anchor"
      },
      "instructions": [
        {
          "name": "initialize",
          "discriminator": [175,175,109,31,13,152,155,237],
          "accounts": [],
          "args": []
        }
      ],
      "accounts": [],
      "types": [],
      "events": [],
      "errors": [],
      "constants": [],
      "state": null
    }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "context": {
    "slot": 355684457,
    "apiVersion": "2.2.2"
  },
  "value": null,
  "id": 1
}
Source

fn get_idl( &self, meta: Self::Metadata, program_id: String, slot: Option<Slot>, ) -> Result<RpcResponse<Option<Idl>>>

A cheat code to get the registered IDL for a given program ID.

§Parameters
  • program_id: The base-58 encoded public key of the program whose IDL is being requested.
  • slot (optional): The slot at which to query the IDL. If omitted, uses the latest slot.
§Returns

A RpcResponse<Option<Idl>> containing the IDL if it exists, or None if not found.

§Example Request (with slot)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_getIdl",
  "params": [
    "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa",
    355684457
  ]
}
§Example Request (without slot)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_getIdl",
  "params": [
    "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa"
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "context": {
    "slot": 355684457,
    "apiVersion": "2.2.2"
  },
  "value": { /* ...IDL object... */ },
  "id": 1
}
Source

fn get_local_signatures( &self, meta: Self::Metadata, limit: Option<u64>, ) -> BoxFuture<Result<RpcResponse<Vec<RpcLogsResponse>>>>

A cheat code to get the last 50 local signatures from the local network.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_getLocalSignatures",
  "params": [ { "limit": 50 } ]
}

## Example Response
```json
{
  "jsonrpc": "2.0",
  "result": {
    "signature": String,
    "err": Option<TransactionError>,
    "slot": u64,
  },
  "id": 1
}
Source

fn time_travel( &self, meta: Self::Metadata, config: Option<TimeTravelConfig>, ) -> Result<EpochInfo>

A cheat code to jump forward or backward in time on the local network. Useful for testing epoch-based or time-sensitive logic.

§Parameters
  • config (optional): A TimeTravelConfig specifying how to modify the clock:
    • absoluteTimestamp(u64): Moves time to the specified UNIX timestamp.
    • absoluteSlot(u64): Moves to the specified absolute slot.
    • absoluteEpoch(u64): Advances time to the specified epoch (each epoch = 432,000 slots).
§Returns

An EpochInfo object reflecting the updated clock state.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_timeTravel",
  "params": [ { "absoluteSlot": 512 } ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "epoch": 512,
    "slot_index": 0,
    "slots_in_epoch": 432000,
    "absolute_slot": 221184000,
    "block_height": 650000000,
    "transaction_count": 923472834
  },
  "id": 1
}
Source

fn pause_clock(&self, meta: Self::Metadata) -> Result<EpochInfo>

A cheat code to freeze the Surfnet clock on the local network. All time progression halts until resumed.

§Returns

An EpochInfo object showing the current clock state at the moment of pause.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_pauseClock",
  "params": []
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "epoch": 512,
    "slot_index": 0,
    "slots_in_epoch": 432000,
    "absolute_slot": 221184000,
    "block_height": 650000000,
    "transaction_count": 923472834
  },
  "id": 1
}
Source

fn resume_clock(&self, meta: Self::Metadata) -> Result<EpochInfo>

A cheat code to resume Solana clock progression after it was paused. The validator will start producing new slots again.

§Parameters
§Returns

An EpochInfo object reflecting the resumed clock state.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_resumeClock",
  "params": []
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "epoch": 512,
    "slot_index": 0,
    "slots_in_epoch": 432000,
    "absolute_slot": 221184000,
    "block_height": 650000000,
    "transaction_count": 923472834
  },
  "id": 1
}
Source

fn reset_account( &self, meta: Self::Metadata, pubkey_str: String, config: Option<ResetAccountConfig>, ) -> Result<RpcResponse<()>>

A cheat code to reset an account on the local network.

§Parameters
  • pubkey_str: The base-58 encoded public key of the account to reset.
  • config: A ResetAccountConfig specifying how to reset the account. If omitted, the account will be reset without cascading to owned accounts.
§Returns

An RpcResponse<()> indicating whether the account reset was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_resetAccount",
  "params": [ "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa", { "includeOwnedAccounts": true } ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 123456789,
      "apiVersion": "2.3.8"
    },
    "value": null
  },
  "id": 1
}
Source

fn reset_network( &self, meta: Self::Metadata, ) -> BoxFuture<Result<RpcResponse<()>>>

A cheat code to reset a network.

§Returns

An RpcResponse<()> indicating whether the network reset was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_resetNetwork",    /// }
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 123456789,
      "apiVersion": "2.3.8"
    },
    "value": null    ///   },
  "id": 1
}
Source

fn offline_account( &self, meta: Self::Metadata, pubkey_str: String, config: Option<OfflineAccountConfig>, ) -> BoxFuture<Result<RpcResponse<()>>>

A cheat code to prevent an account from being downloaded from the remote RPC.

§Parameters
  • pubkey_str: The base-58 encoded public key of the account/program to block.
  • config: A OfflineAccountConfig specifying whether to also mark accounts offline owned by this pubkey. If omitted, only the account itself is marked offline.
§Returns

An RpcResponse<()> indicating whether the download block registration was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_offlineAccount",
  "params": [ "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa", { "includeOwnedAccounts": true } ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 123456789,
      "apiVersion": "2.3.8"
    },
    "value": null
  },
  "id": 1
}
Source

fn export_snapshot( &self, meta: Self::Metadata, config: Option<ExportSnapshotConfig>, ) -> Result<RpcResponse<BTreeMap<String, AccountSnapshot>>>

A cheat code to export a snapshot of all accounts in the Surfnet SVM.

This method retrieves the current state of all accounts stored in the Surfnet Virtual Machine (SVM) and returns them as a mapping of account public keys to their respective account snapshots.

§Parameters
  • config: An optional ExportSnapshotConfig to customize the export behavior. The config fields are:
    • includeParsedAccounts: If true, includes parsed account data in the snapshot.
    • filter: An optional filter config to limit which accounts are included in the snapshot. Fields include:
      • includeProgramAccounts: A boolean indicating whether to include program accounts.
      • includeAccounts: A list of specific account public keys to include.
      • excludeAccounts: A list of specific account public keys to exclude.
    • scope: An optional scope to limit the accounts included in the snapshot. Options include:
      • network: Includes all accounts in the network.
      • preTransaction: Only includes accounts touched by the given transaction.
§Returns

An RpcResponse<BTreeMap<String, AccountSnapshot>> containing the exported account snapshots.

The keys of the map are the base-58 encoded public keys of the accounts, and the values are the corresponding AccountSnapshot objects.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_exportSnapshot"
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa": {
      "lamports": 1000000,
      "owner": "11111111111111111111111111111111",
      "executable": false,
      "rent_epoch": 0,
      "data": "base64_encoded_data_string"
    },
    "AnotherAccountPubkeyBase58": {
      "lamports": 500000,
      "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
      "executable": false,
      "rent_epoch": 0,
      "data": "base64_encoded_data_string"
    }
  },
  "id": 1
}
Source

fn stream_account( &self, meta: Self::Metadata, pubkey_str: String, config: Option<StreamAccountConfig>, ) -> Result<RpcResponse<()>>

A cheat code to simulate account streaming. When a transaction is processed, the accounts that are accessed are downloaded from the datasource and cached in the SVM. With this method, you can simulate the streaming of accounts by providing a pubkey.

§Parameters
  • pubkey_str: The base-58 encoded public key of the account to stream.
  • config: A StreamAccountConfig specifying how to stream the account. If omitted, the account will be streamed without cascading to owned accounts.
§Returns

An RpcResponse<()> indicating whether the account stream registration was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_streamAccount",
  "params": [ "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa", { "includeOwnedAccounts": true } ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 123456789,
      "apiVersion": "2.3.8"
    },
    "value": null
  },
  "id": 1
}
Source

fn stream_accounts( &self, meta: Self::Metadata, accounts: Vec<StreamAccountsEntry>, ) -> Result<RpcResponse<()>>

A cheat code to simulate account streaming for multiple accounts at once. When a transaction is processed, the accounts that are accessed are downloaded from the datasource and cached in the SVM. With this method, you can simulate the streaming of multiple accounts by providing a list of entries.

§Parameters
  • accounts: A list of StreamAccountsEntry objects, each containing a pubkey (base-58 encoded) and an optional includeOwnedAccounts boolean.
§Returns

An RpcResponse<()> indicating whether the account stream registrations were successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_streamAccounts",
  "params": [
    [
      { "pubkey": "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa", "includeOwnedAccounts": true },
      { "pubkey": "7nYBm5mk15oDNewVjNFmEqJ9VgMvT4F74UVoeYDCpScd" }
    ]
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 123456789,
      "apiVersion": "2.3.8"
    },
    "value": null
  },
  "id": 1
}
Source

fn get_streamed_accounts( &self, meta: Self::Metadata, ) -> Result<RpcResponse<GetStreamedAccountsResponse>>

A cheat code to retrieve the streamed accounts. When a transaction is processed, the accounts that are accessed are downloaded from the datasource and cached in the SVM. With this method, you can simulate the streaming of accounts by providing a pubkey.

§Parameters
§Returns

An RpcResponse<()> indicating whether the account stream registration was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_getStreamedAccounts",
  "params": []
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 123456789,
      "apiVersion": "2.3.8"
    },
    "value": [
      "4EXSeLGxVBpAZwq7vm6evLdewpcvE2H56fpqL2pPiLFa"
    ]
   },
  "id": 1
}
Source

fn get_surfnet_info( &self, meta: Self::Metadata, ) -> Result<RpcResponse<GetSurfnetInfoResponse>>

A cheat code to get Surfnet network information.

§Returns

A RpcResponse<GetSurfnetInfoResponse> containing the Surfnet network information.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_getSurfnetInfo"
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {
    "context": {
      "slot": 369027326,
      "apiVersion": "2.3.8"
    },
    "value": {
      "runbookExecutions": [
        {
          "startedAt": 1758747828,
          "completedAt": 1758747828,
          "runbookId": "deployment"
        }
      ]
    }
  },
  "id": 1
}
Source

fn write_program( &self, meta: Self::Metadata, program_id: String, data: String, offset: usize, authority: Option<String>, ) -> BoxFuture<Result<RpcResponse<()>>>

A “cheat code” method for developers to write program data at a specified offset in Surfpool.

This method allows developers to write large Solana programs by sending data in chunks, bypassing transaction size limits by using RPC size limits (5MB) instead.

§Parameters
  • program_id: The public key of the program account, as a base-58 encoded string.
  • data: Hex-encoded program data chunk to write.
  • offset: The byte offset at which to write this data chunk.
  • authority (optional): The base-58 encoded public key of the authority allowed to write to the program. If omitted, defaults to the system program.
§Returns

A RpcResponse<()> indicating whether the write was successful.

§Example Request
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_writeProgram",
  "params": [
    "program_pubkey",
    "deadbeef...",
    0
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "result": {},
  "id": 1
}
§Notes

This method is designed to help developers deploy large programs by writing data incrementally. Multiple calls can be made with different offsets to build the complete program. The program account and program data account will be created automatically if they don’t exist.

Source

fn register_scenario( &self, meta: Self::Metadata, scenario: Scenario, slot: Option<Slot>, ) -> Result<RpcResponse<()>>

A cheat code to register a scenario with account overrides.

§Parameters
  • scenario: The Scenario object containing:
    • id: Unique identifier for the scenario
    • name: Human-readable name
    • description: Description of the scenario
    • overrides: Array of OverrideInstance objects, each containing:
      • id: Unique identifier for this override instance
      • templateId: Reference to the override template
      • values: HashMap of field paths to override values
      • scenarioRelativeSlot: The relative slot offset (from base slot) when this override should be applied
      • label: Optional label for this override
      • enabled: Whether this override is active
      • fetchBeforeUse: If true, fetch fresh account data just before transaction execution (useful for price feeds, oracle updates, and dynamic balances)
      • account: Account address (either { "pubkey": "..." } or { "pda": { "programId": "...", "seeds": [...] } })
    • tags: Array of tags for categorization
  • slot (optional): The base slot from which relative slot offsets are calculated. If omitted, uses the current slot.
§Returns

A RpcResponse<()> indicating whether the Scenario registration was successful.

§Example Request (with slot)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_registerScenario",
  "params": [
    {
      "id": "scenario-1",
      "name": "Price Feed Override",
      "description": "Override Pyth BTC/USD price at specific slots",
      "overrides": [
        {
          "id": "override-1",
          "templateId": "pyth_btcusd",
          "values": {
            "price_message.price_value": 67500,
            "price_message.conf": 100,
            "price_message.expo": -8
          },
          "scenarioRelativeSlot": 100,
          "label": "Set BTC price to $67,500",
          "enabled": true,
          "fetchBeforeUse": false,
          "account": {
            "pubkey": "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4QJNYH"
          }
        }
      ],
      "tags": ["defi", "price-feed"]
    },
    355684457
  ]
}
§Example Request (without slot)
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "surfnet_registerScenario",
  "params": [
    {
      "id": "scenario-1",
      "name": "Price Feed Override",
      "description": "Override Pyth BTC/USD price",
      "overrides": [
        {
          "id": "override-1",
          "templateId": "pyth_btcusd",
          "values": {
            "price_message.price_value": 67500
          },
          "scenarioRelativeSlot": 100,
          "label": "Set BTC price",
          "enabled": true,
          "fetchBeforeUse": true,
          "account": {
            "pubkey": "H6ARHf6YXhGYeQfUzQNGk6rDNnLBQKrenN712K4QJNYH"
          }
        }
      ],
      "tags": []
    }
  ]
}
§Example Response
{
  "jsonrpc": "2.0",
  "context": {
    "slot": 355684457,
    "apiVersion": "2.2.2"
  },
  "value": null,
  "id": 1
}

Provided Methods§

Source

fn to_delegate(self) -> IoDelegate<Self, Self::Metadata>

Create an IoDelegate, wiring rpc calls to the trait methods.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§