跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.solanatracker.io/llms.txt

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

这能做什么

  • 以低延迟发送交易
  • 实时追踪确认状态
  • 自动重试未确认的交易
  • 返回解析后的交易数据和 Raptor 事件
  • 测量发送 → 确认的延迟

发送交易

发送已签名的 Solana 交易。 端点 POST /send-transaction 请求体
{
  "transaction": "base64-encoded-transaction"
}
响应
{
  "signature": "4vJ9JU1bJJE96FWSJKvHsmmFADCg4gpZQff4P3bkLKi",
  "signature_base64": "RXNzaWduYXR1cmU=",
  "success": true
}
注意
  • 接受交易后立即返回
  • 发送和重试在后台进行
  • 交易会重试最多 30 秒或直到确认

追踪交易

检查通过 /send-transaction 发送的交易状态。 端点
  • GET /transaction/{signature}
签名可以是 base58 或 base64 响应(示例)
{
  "signature": "4vJ9JU1bJJE96FWSJKvHsmmFADCg4gpZQff4P3bkLKi",
  "status": "confirmed",
  "slot": 250123456,
  "sent_at": 1703123456789,
  "confirmed_at": 1703123456795,
  "latency_ms": 6,
  "transaction": { ... },
  "events": [ ... ]
}

状态值

  • pending – 已发送但未确认
  • confirmed – 在 confirmed 确认级别被接受
  • failed – 交易错误
  • expired – 在超时前未确认

Raptor 事件

如果交易与 Raptor 程序交互,事件会被自动解析并返回。 支持的事件
  • SwapEvent
  • SwapCompleteEvent
  • PlaceOrderEvent
  • FillOrderEvent
  • CancelOrderEvent
  • UpdateOrderEvent
事件格式
{
  "name": "SwapEvent",
  "data": "base64-encoded-data",
  "parsed": {
    "dex": 1,
    "amountIn": 1000000,
    "amountOut": 999000
  }
}

示例

发送交易

const RAPTOR_URL = 'https://raptor-beta.solanatracker.io';

const response = await fetch(`${RAPTOR_URL}/send-transaction`, {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ transaction: signedTx })
});

const result = await response.json();
console.log(result.signature);

轮询等待确认

async function waitForConfirmation(signature) {
  for (let i = 0; i < 30; i++) {
    const res = await fetch(`${RAPTOR_URL}/transaction/${signature}`);
    const tx = await res.json();

    if (tx.status === 'confirmed' || tx.status === 'failed') {
      return tx;
    }

    await new Promise(r => setTimeout(r, 1000));
  }

  throw new Error('Timeout');
}

读取兑换结果

const RAPTOR_URL = 'https://raptor-beta.solanatracker.io';
const tx = await fetch(`${RAPTOR_URL}/transaction/${signature}`).then(r => r.json());

for (const event of tx.events ?? []) {
  if (event.name === 'SwapEvent') {
    console.log(event.parsed.amountIn, '→', event.parsed.amountOut);
  }
}

错误

代码含义
400无效交易
404交易未被追踪
503发送器或追踪已禁用
{
  "error": "Transaction not found",
  "code": 404
}