JS APIリファレンス

@solana/surfpoolパッケージは、Surfnetというクラスと、そのメソッドを型安全に呼び出すために必要なサポート型を公開しています。このページでは、エクスポートされたすべてのシンボルを一覧表示しています。実際の使い方については、概要から始まるガイドをご覧ください。

パッケージエクスポート

シンボル種類説明
Surfnetクラスチートコードメソッドを持つSurfnetの実行インスタンス
SurfnetConfigSurfnet.startWithConfigの引数
DeployOptionsSurfnet.deployの引数
SetTokenAccountUpdateSurfnet.setTokenAccountの引数
ResetAccountOptionsSurfnet.resetAccountの引数
StreamAccountOptionsSurfnet.streamAccountの引数
SolAccountFundingSurfnet.fundSolManyに渡される配列の要素
SimnetEventValueSurfnet.drainEventsが返す要素
KeypairInfoSurfnet.newKeypairが返す値
ClockValueSimnetEventValueのフィールド
EpochInfoValueタイムトラベルヘルパーが返す値
ByteArrayLikeUint8Array | number[] — 柔軟なバイト入力

Surfnetクラス

静的メソッド

class Surfnet {
static start(): Surfnet;
static startWithConfig(config: SurfnetConfig): Surfnet;
static newKeypair(): KeypairInfo;
}

インスタンスプロパティ

class Surfnet {
readonly rpcUrl: string; // http://127.0.0.1:<port>
readonly wsUrl: string; // ws://127.0.0.1:<port>
readonly payer: string; // base58 public key
readonly payerSecretKey: Uint8Array; // 64-byte private key
readonly instanceId: string;
}

ライフサイクル

class Surfnet {
stop(): void; // idempotent; safe to call from `finally` / test teardown
}

SOLチートコード

class Surfnet {
fundSol(address: string, lamports: number): void;
fundSolMany(accounts: SolAccountFunding[]): void;
setAccount(
address: string,
lamports: number,
data: Uint8Array,
owner: string
): void;
resetAccount(address: string, options?: ResetAccountOptions): void;
}

トークンチートコード

class Surfnet {
fundToken(
owner: string,
mint: string,
amount: number,
tokenProgram?: string
): void;
fundTokenMany(
owners: string[],
mint: string,
amount: number,
tokenProgram?: string
): void;
setTokenBalance(
owner: string,
mint: string,
amount: number,
tokenProgram?: string
): void;
setTokenAccount(
owner: string,
mint: string,
update: SetTokenAccountUpdate,
tokenProgram?: string
): void;
getAta(owner: string, mint: string, tokenProgram?: string): string;
}

タイムトラベル

class Surfnet {
timeTravelToSlot(slot: number): EpochInfoValue;
timeTravelToEpoch(epoch: number): EpochInfoValue;
timeTravelToTimestamp(timestampMs: number): EpochInfoValue;
}

プログラムのデプロイ

class Surfnet {
deployProgram(programName: string): string; // returns program id
deploy(options: DeployOptions): string; // returns program id
}

ストリーミングとイベント

class Surfnet {
streamAccount(address: string, options?: StreamAccountOptions): void;
drainEvents(): SimnetEventValue[];
}

設定タイプ

SurfnetConfig

interface SurfnetConfig {
offline?: boolean; // default: true
remoteRpcUrl?: string; // setting this implies offline=false
blockProductionMode?: "manual" | "clock" | "transaction"; // default: "transaction"
slotTimeMs?: number; // default: 1
airdropSol?: number; // lamports; default: 10_000_000_000
airdropAddresses?: string[];
payerSecretKey?: ByteArrayLike;
enableFeatures?: string[]; // feature IDs (base58 or kebab name)
disableFeatures?: string[];
allFeatures?: boolean;
}

DeployOptions

interface DeployOptions {
programId: string; // base58 address
soPath?: string; // mutually exclusive with soBytes
soBytes?: ByteArrayLike;
idlPath?: string; // optional Anchor IDL JSON
}

SetTokenAccountUpdate

interface SetTokenAccountUpdate {
amount?: number;
delegate?: string; // base58 pubkey
clearDelegate?: boolean;
state?: string; // e.g. "initialized", "frozen"
delegatedAmount?: number;
closeAuthority?: string;
clearCloseAuthority?: boolean;
}

ResetAccountOptions

interface ResetAccountOptions {
includeOwnedAccounts?: boolean;
}

StreamAccountOptions

interface StreamAccountOptions {
includeOwnedAccounts?: boolean;
}

SolAccountFunding

interface SolAccountFunding {
address: string;
lamports: number;
}

KeypairInfo

interface KeypairInfo {
publicKey: string; // base58
secretKey: number[]; // 64 bytes
}

ByteArrayLike

type ByteArrayLike = Uint8Array | number[];

メソッドが ByteArrayLike を受け付ける場合、Uint8Array または通常の数値配列のいずれかを渡すことができます。このラッパーは、どちらもネイティブバインディングが期待する形式に正規化します。

イベントタイプ

SimnetEventValue

kind ディスクリミネーターとオプションフィールドを持つフラットオブジェクトです。バリアントのカタログについては イベントを参照してください。

interface SimnetEventValue {
kind: string;
message?: string;
timestamp?: string;
initialTransactionCount?: number;
clock?: ClockValue;
epochInfo?: EpochInfoValue;
accountPubkey?: string;
clockCommand?: string;
slotIntervalMs?: number;
transactionSignature?: string;
logs?: string[];
computeUnitsConsumed?: number;
fee?: number;
errorMessage?: string;
tag?: string;
profileKey?: string;
profileSlot?: number;
runbookId?: string;
runbookErrors?: string[];
}

ClockValue

interface ClockValue {
slot: number;
epoch: number;
leaderScheduleEpoch: number;
unixTimestamp: number;
epochStartTimestamp: number;
}

EpochInfoValue

interface EpochInfoValue {
absoluteSlot: number;
slotIndex: number;
slotsInEpoch: number;
epoch: number;
blockHeight: number;
transactionCount?: number;
}

エラー

すべてのメソッドは、標準の Error をスローします。そのメッセージは、基盤となる Rust の SurfnetError をラップしています。ケースを判別するには error.message を検査してください。

try {
surfnet.deploy({ programId, soPath: "missing.so" });
} catch (err) {
// err.message starts with "Cheatcode:" / "Startup:" / etc.
console.error(err);
}

ネイティブモジュールのフットプリント

このパッケージは、optionalDependencies として公開されているプラットフォーム固有のネイティブバイナリに依存しています:

トリプルパッケージ
aarch64-apple-darwin@solana/surfpool-darwin-arm64
x86_64-apple-darwin@solana/surfpool-darwin-x64
x86_64-unknown-linux-gnu@solana/surfpool-linux-x64-gnu

プラットフォームパッケージがいずれもお使いのマシンにインストールされない場合、Surfnet.start() は初回呼び出し時に「ネイティブモジュールが見つかりません」という明確なエラーをスローします。サポートマトリックスとトラブルシューティングについては、インストールをご参照ください。

Is this page helpful?

© 2026 Solana Foundation. 無断転載を禁じます。