Ana içeriğe atla

Documentation Index

Fetch the complete documentation index at: https://docs.orbitflare.com/llms.txt

Use this file to discover all available pages before exploring further.

Kurulum

npm install @orbitflare/sdk @grpc/grpc-js yaml
@grpc/grpc-js ve yaml isteğe bağlı peer bağımlılıklardır. Yalnızca JetStream (veya YAML yapılandırması) kullanıyorsanız kurun.

İstemciyi oluşturma

import { JetstreamClientBuilder, type RetryPolicy } from '@orbitflare/sdk';

const client = new JetstreamClientBuilder()
  .url('http://ny.jetstream.orbitflare.com')
  .fallbackUrl('http://fra.jetstream.orbitflare.com')
  .retry({
    initialDelayMs: 100,
    maxDelayMs: 30_000,
    multiplier: 2.0,
    maxAttempts: 0,
  })
  .timeoutSecs(30)
  .keepaliveSecs(60)
  .pingIntervalSecs(10)
  .maxMissedPongs(3)
  .channelCapacity(4096)
  .build();
Minimal:
const client = new JetstreamClientBuilder()
  .url('http://ny.jetstream.orbitflare.com')
  .build();
URL, ayarlanmazsa ORBITFLARE_JETSTREAM_URL ortam değişkenine düşer. Tüm builder yöntemleri gRPC istemcisi ile aynıdır - aynı varsayılanlar, aynı davranış.

YAML yapılandırması yazma

JetStream işlem ve hesap filtrelerini destekler. Slot, blok veya taahhüt yok - bunlar Yellowstone’a özgüdür.
# jetstream.yml
transactions:
  raydium:
    account_include:
      - "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"
  pumpfun:
    account_include:
      - "6EF8rrecthR5Dkzon8Nwu78hRvfCKubJ14M5uBEwF6P"

accounts:
  my_wallet:
    account:
      - "YOUR_WALLET_ADDRESS"
    owner:
      - "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"

YAML filtre referansı

transactions - adlı filtreler. account_include, bu adresleri içeren işlemlerle eşleşir. account_exclude eşleşmeleri çıkarır. account_required listelenen tüm adreslerin görünmesini gerektirir. accounts - account ile belirli adresleri veya owner ile bir programa ait tüm hesapları izleyin. ${ENV_VAR} genişletmesini destekler.

Olaylara abone olma ve okuma

YAML’dan

const stream = client.subscribeYaml('jetstream.yml');

Programatik olarak

import { proto } from '@orbitflare/sdk';

const request: proto.jetstream.SubscribeRequest = {
  transactions: {
    target: {
      accountInclude: [someAddress],
      accountExclude: [],
      accountRequired: [],
    },
  },
  accounts: {},
  ping: { id: 1 },
};

const stream = client.subscribe(request);

Akışı okuma

for await (const update of stream) {
  if (update.transaction) {
    // update.transaction.slot - the slot number
    // update.transaction.transaction - transaction info with signature, accountKeys,
    //   instructions, addressTableLookups
  } else if (update.account) {
    // update.account.slot - the slot
    // update.account.account - account info (pubkey, lamports, owner, data)
    // update.account.isStartup - true during initial snapshot
  }
}
Kapatma, birden çok akış, yeniden bağlanma ve ping/pong, gRPC istemcisi ile birebir aynı şekilde çalışır.

Tam örnek

Raydium AMM takaslarını izleyen ve her işlemin imzası ile talimat sayısını yazdıran bir akış.
import bs58 from 'bs58';
import { JetstreamClientBuilder } from '@orbitflare/sdk';

async function main() {
  const client = new JetstreamClientBuilder()
    .url('http://ny.jetstream.orbitflare.com')
    .build();

  const stream = client.subscribeYaml('jetstream.yml');
  let count = 0;

  console.log('streaming raydium txs...');

  for await (const update of stream) {
    if (update.transaction) {
      count += 1;
      const info = update.transaction.transaction;
      if (info?.signature) {
        const sig = bs58.encode(info.signature);
        const numIx = info.instructions.length;
        const numAccounts = info.accountKeys.length;
        console.log(
          `#${count} slot=${update.transaction.slot} sig=${sig.slice(0, 16)}... ix=${numIx} accounts=${numAccounts}`,
        );
      }
    }
  }
}

void main();
Bu jetstream.yml ile:
transactions:
  raydium:
    account_include:
      - "675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8"