JS API Referansı

@solana/surfpool paketi, Surfnet adlı tek bir sınıfı ve metodlarını tip güvenli biçimde çağırmak için ihtiyaç duyduğunuz yardımcı türleri sunar. Bu sayfa, dışa aktarılan tüm sembolleri listeler; anlatım odaklı kullanım için Genel Bakış ile başlayan kılavuzlara bakın.

Paket Dışa Aktarımları

SembolTürNotlar
SurfnetsınıfHile kodu metodlarına sahip çalışan Surfnet örneği
SurfnetConfigtürSurfnet.startWithConfig için argüman
DeployOptionstürSurfnet.deploy için argüman
SetTokenAccountUpdatetürSurfnet.setTokenAccount için argüman
ResetAccountOptionstürSurfnet.resetAccount için argüman
StreamAccountOptionstürSurfnet.streamAccount için argüman
SolAccountFundingtürSurfnet.fundSolMany'e iletilen dizinin elemanı
SimnetEventValuetürSurfnet.drainEvents tarafından döndürülen eleman
KeypairInfotürSurfnet.newKeypair tarafından döndürülür
ClockValuetürSimnetEventValue üzerindeki alan
EpochInfoValuetürZaman yolculuğu yardımcıları tarafından döndürülür
ByteArrayLiketürUint8Array | number[] — esnek bayt girişi

Surfnet Sınıfı

Statik Metodlar

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

Örnek Özellikleri

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;
}

Yaşam Döngüsü

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

SOL Hile Kodları

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;
}

Token Hile Kodları

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;
}

Zaman Yolculuğu

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

Program Dağıtımı

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

Akış & Olaylar

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

Yapılandırma Türleri

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[];

Bir metot ByteArrayLike kabul ettiğinde, Uint8Array veya düz bir sayı dizisi geçirebilirsiniz. Sarmalayıcı, her ikisini de yerel bağlamanın beklediği biçime normalleştirir.

Olay Türleri

SimnetEventValue

kind ayrımcısına ve isteğe bağlı alanlara sahip düz bir nesne. Varyant kataloğu için Olaylar sayfasına bakın.

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;
}

Hatalar

Her metot, mesajı temel alınan Rust SurfnetError hatasını saran standart bir Error fırlatır. Durumlar arasında ayrım yapmak için error.message değerini inceleyin.

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

Yerel Modül Kaplama Alanı

Paket, şu şekilde yayımlanan platforma özgü yerel ikili dosyalara bağlıdır: optionalDependencies:

ÜçlüPaket
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

Platform paketlerinden hiçbiri makinenize yüklenmezse, Surfnet.start() ilk çağrıda "yerel modül bulunamadı" şeklinde açık bir hata fırlatır. Destek matrisi ve sorun giderme için bkz. Kurulum.

Is this page helpful?

© 2026 Solana Vakfı. Tüm hakları saklıdır.