Skip to content
/ surfman Public

A comprehensive SDK and CLI tool for interacting with SurfPool RPC APIs

Notifications You must be signed in to change notification settings

ennea8/surfman

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Surfman

A comprehensive SDK and CLI tool for interacting with SurfPool RPC APIs.

Features

  • 🎯 SDK Library - Type-safe SDK for programmatic API interaction
  • ⚑ CLI Tool - Command-line interface for quick operations
  • 🌐 Web UI - Browser-based interface (coming soon)
  • πŸ”Œ WebSocket Support - Real-time state updates (planned)

Architecture

Surfman is built as a monorepo using pnpm workspaces:

  • @surfman/sdk - Core SDK library for programmatic use
  • @surfman/cli - CLI tool for command-line operations
  • @surfman/web - Web UI (coming soon)

Supported APIs

Cheatcodes Module (22/22 APIs) βœ… COMPLETE

  • βœ… surfnet_timeTravel - Time manipulation
  • βœ… surfnet_setAccount - Account modification
  • βœ… surfnet_setProgramAuthority - Program authority management
  • βœ… surfnet_pauseClock - Pause clock
  • βœ… surfnet_resumeClock - Resume clock
  • βœ… surfnet_getLocalSignatures - Get recent signatures
  • βœ… surfnet_setTokenAccount - Token account updates
  • βœ… surfnet_resetAccount - Reset account
  • βœ… surfnet_resetNetwork - Reset network
  • βœ… surfnet_cloneProgramAccount - Clone program accounts
  • βœ… surfnet_profileTransaction - Profile transactions for compute units
  • βœ… surfnet_getProfileResultsByTag - Get profiling results by tag
  • βœ… surfnet_setSupply - Configure network supply
  • βœ… surfnet_getTransactionProfile - Get transaction profile by signature/UUID
  • βœ… surfnet_registerIdl - Register program IDL
  • βœ… surfnet_getActiveIdl - Get registered IDL
  • βœ… surfnet_exportSnapshot - Export account snapshots
  • βœ… surfnet_streamAccount - Stream accounts from data source
  • βœ… surfnet_getStreamedAccounts - Get all streamed accounts
  • βœ… surfnet_getSurfnetInfo - Get Surfnet network information
  • βœ… surfnet_writeProgram - Write program data in chunks
  • βœ… surfnet_registerScenario - Register scenarios with account overrides

Network Health Module (22/22 APIs) βœ… COMPLETE

  • βœ… getLatestBlockhash - Get latest blockhash
  • βœ… getBlock - Get block details
  • βœ… getBlocks - Get confirmed blocks
  • βœ… getBlocksWithLimit - Get blocks with limit
  • βœ… getBlockTime - Get block timestamp
  • βœ… getFirstAvailableBlock - Get first available block
  • βœ… minimumLedgerSlot - Get minimum ledger slot
  • βœ… getTransaction - Get transaction details
  • βœ… getSignatureStatuses - Get signature statuses
  • βœ… getSignaturesForAddress - Get address transaction history
  • βœ… sendTransaction - Send transaction
  • βœ… simulateTransaction - Simulate transaction
  • βœ… isBlockhashValid - Validate blockhash
  • βœ… getFeeForMessage - Get transaction fee
  • βœ… getRecentPrioritizationFees - Get recent priority fees
  • βœ… getClusterNodes - Get cluster node info
  • βœ… getRecentPerformanceSamples - Get performance samples
  • βœ… requestAirdrop - Request SOL airdrop
  • βœ… getInflationReward - Get inflation rewards
  • βœ… getMaxRetransmitSlot - Get max retransmit slot
  • βœ… getMaxShredInsertSlot - Get max shred insert slot
  • βœ… getStakeMinimumDelegation - Get minimum stake delegation

Accounts Data Module (5/5 APIs) βœ… COMPLETE

  • βœ… getAccountInfo - Get account details
  • βœ… getMultipleAccounts - Batch account query
  • βœ… getBlockCommitment - Get block commitment
  • βœ… getTokenAccountBalance - Get token balance
  • βœ… getTokenSupply - Get token supply

Accounts Scan Module (6/6 APIs) βœ… COMPLETE

  • βœ… getProgramAccounts - Get program-owned accounts
  • βœ… getLargestAccounts - Get top accounts by balance
  • βœ… getSupply - Get network supply info
  • βœ… getTokenLargestAccounts - Get largest token holders
  • βœ… getTokenAccountsByOwner - Get token accounts by owner
  • βœ… getTokenAccountsByDelegate - Get delegated token accounts

Installation

Install CLI globally

npm install -g surfman

Install SDK in your project

npm install @surfman/sdk

Quick Start

CLI Usage

Development (run directly from source):

# Time travel forward 1 week
pnpm cli time-travel --relative +1w

# Set account data
pnpm cli set-account --pubkey <ADDRESS> --lamports 1000000

# Set program authority
pnpm cli set-program-authority --program-id <ID> --new-authority <ADDRESS>

Production (after installing globally):

npm install -g surfman

surfman time-travel --relative +1w
surfman set-account --pubkey <ADDRESS> --lamports 1000000
surfman set-program-authority --program-id <ID> --new-authority <ADDRESS>

SDK Usage

import { Surfman } from '@surfman/sdk';

const client = new Surfman('http://localhost:8899');

// Cheatcodes - Time Control
await client.cheatcodes.timeTravel({ absoluteEpoch: 100 });
await client.cheatcodes.pauseClock();
await client.cheatcodes.resumeClock();

// Cheatcodes - Account Management
await client.cheatcodes.setAccount(pubkey, { lamports: 1000000 });
await client.cheatcodes.setTokenAccount(owner, mint, { amount: 1000 });
await client.cheatcodes.resetAccount(pubkey);
await client.cheatcodes.resetNetwork();

// Cheatcodes - Advanced Features
await client.cheatcodes.cloneProgramAccount(sourceProgram, destProgram);
await client.cheatcodes.profileTransaction(txData, 'my-tag');
await client.cheatcodes.setSupply({ total: 1000000000 });
await client.cheatcodes.registerIdl(idl);
const snapshot = await client.cheatcodes.exportSnapshot();
await client.cheatcodes.writeProgram(programId, hexData, offset);

// Network Health
const blockhash = await client.network.getLatestBlockhash();
const block = await client.network.getBlock(1000);
const tx = await client.network.getTransaction(signature);
const signature = await client.network.sendTransaction(txData);

// Accounts Data
const account = await client.accounts.getAccountInfo(pubkey);
const accounts = await client.accounts.getMultipleAccounts([pubkey1, pubkey2]);
const balance = await client.accounts.getTokenAccountBalance(tokenAccount);

// Accounts Scan
const programAccounts = await client.scan.getProgramAccounts(programId);
const largestAccounts = await client.scan.getLargestAccounts();
const supply = await client.scan.getSupply();
const tokenHolders = await client.scan.getTokenLargestAccounts(mint);
const ownerTokens = await client.scan.getTokenAccountsByOwner(owner, { mint });

// Set account
await client.cheatcodes.setAccount('pubkey', {
  lamports: 1000000,
  data: 'hex-data'
});

Development

# Install dependencies
pnpm install

# Build all packages
pnpm build

# Run in development mode
pnpm dev

# Run tests
pnpm test

Documentation

Full documentation available at: https://docs.surfpool.run/rpc/surfnet

License

MIT

About

A comprehensive SDK and CLI tool for interacting with SurfPool RPC APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages