> ## Documentation Index
> Fetch the complete documentation index at: https://www.helius.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Senderとのランド取引

> Helius Senderを使用して低レイテンシの送信ループを構築します：地域別エンドポイント、接続ウォーミング、動的優先手数料、ヒント、および再試行を伴う着陸確認。

Senderは、高速パスウェイ（Helius、Jito、Harmonic、Rakurai）のすべてを横断してトランザクションを同時に送信し、APIクレジットを消費しません。送信ごとにSOLチップで支払いを行います。このガイドは、温かい接続、ライブ価格の手数料、再試行ポリシーによる確認を備えた実際の送信ループを構築します。

## タイアの選択

[Sender Max](/docs/ja/sending-transactions/sender-max) (最低0.001 SOLのチップ) はすべてのパスウェイを経由し、優先チップバッファーに入り、大きなチップが最初に着陸します。

[SWQOS-only](/docs/ja/sending-transactions/sender-swqos-only) (0.000005 SOL) はコスト最適化された単一の高速パスを取ります。エンドポイントURLに`?swqos_only=true`を追加します。

2つの最低限の間のチップは、いくつかのパスウェイを通過するベストエフォートなので、どちらかのティアを選ぶ必要があります。

## エンドポイントの選択

バックエンドはサーバーに最も近い地域のHTTPエンドポイントを使用するべきです（`http://ewr-sender.helius-rpc.com/fast`、`fra`、`slc`、`ams`、`lon`、`sg`、`tyo`）。

ブラウザは、グローバルHTTPSエンドポイント`https://sender.helius-rpc.com/fast`を使用すべきです。これにより、自動ルーティングが行われ、CORSの問題が回避されます。

## 接続をウォームアップする

コールドTCP/TLSハンドシェイクは、アイドル期間後の最初の送信にレイテンシを追加します。

システムが5秒以上送信しない可能性がある場合、pingエンドポイントを使用して接続を温存します：

```typescript theme={"system"}
const SENDER = 'http://ewr-sender.helius-rpc.com';

setInterval(async () => {
  try {
    await fetch(`${SENDER}/ping`);
  } catch (e) {
    console.warn('warm-up failed:', e);
  }
}, 5_000);
```

## トランザクションの構築

すべてのSenderトランザクションには、指定されたチップアカウントへのチップ転送と計算単位価格の両方を含める必要があります。どちらかが欠けているトランザクションはSenderにより拒否されます。

優先手数料をハードコーディングすると、静かな市場では過剰支払いをし、忙しい市場では競争に負けることになります。したがって、[Priority Fee API](/docs/ja/priority-fee-api)から価格を設定します：

```typescript send.ts theme={"system"}
import {
  Connection, TransactionMessage, VersionedTransaction,
  SystemProgram, PublicKey, Keypair, ComputeBudgetProgram, LAMPORTS_PER_SOL
} from '@solana/web3.js';

const RPC = 'https://mainnet.helius-rpc.com/?api-key=YOUR_API_KEY';
const TIP_ACCOUNTS = [
  '4ACfpUFoaSD9bfPdeu6DBt89gB6ENTeHBXCAi87NhDEE',
  'D2L6yPZ2FmmmTKPgzaMKdhu6EWZcTpLy1Vhx8uvZe7NZ',
  '9bnz4RShgq1hAnLnZbP8kbgBg1kEmcJBYQq3gQbmnSta'
];

async function buildTransaction(keypair: Keypair, tradeInstructions: any[]) {
  const connection = new Connection(RPC);
  const { blockhash } = await connection.getLatestBlockhash('confirmed');

  // Price the fee against the accounts the trade touches
  const feeRes = await fetch(RPC, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0', id: '1', method: 'getPriorityFeeEstimate',
      params: [{
        accountKeys: tradeInstructions.flatMap(ix => ix.keys.map((k: any) => k.pubkey.toBase58())),
        options: { recommended: true }
      }]
    })
  });
  const { result } = await feeRes.json();

  const tx = new VersionedTransaction(
    new TransactionMessage({
      instructions: [
        ComputeBudgetProgram.setComputeUnitLimit({ units: 100_000 }),
        ComputeBudgetProgram.setComputeUnitPrice({ microLamports: result.priorityFeeEstimate }),
        ...tradeInstructions,
        SystemProgram.transfer({
          fromPubkey: keypair.publicKey,
          toPubkey: new PublicKey(TIP_ACCOUNTS[Math.floor(Math.random() * TIP_ACCOUNTS.length)]),
          lamports: 0.001 * LAMPORTS_PER_SOL // Sender Max minimum; tip more to land first
        })
      ],
      payerKey: keypair.publicKey,
      recentBlockhash: blockhash
    }).compileToV0Message()
  );
  tx.sign([keypair]);
  return tx;
}
```

チップはトランザクションが通過できるパスウェイを決定し、優先手数料はバリデーターキュー内の位置を上げます。これらが一緒になって、含まれる確率を最大化します。

## 送信し、確認する

クライアント側の検証を低レイテンシのために交換するには`skipPreflight: true`を使用して送信し、RPC接続を通じて確認します。

Senderは署名を直ちに返しますが、これは着陸の証明ではありません：

```typescript theme={"system"}
async function sendAndConfirm(tx: VersionedTransaction): Promise<string> {
  const signature = await send(tx);

  const connection = new Connection(RPC);
  for (let i = 0; i < 30; i++) {
    const { value } = await connection.getSignatureStatuses([signature]);
    const status = value[0];
    if (status?.err) throw new Error(`Transaction failed: ${JSON.stringify(status.err)}`);
    if (status?.confirmationStatus === 'confirmed' || status?.confirmationStatus === 'finalized') {
      return signature;
    }
    await new Promise(r => setTimeout(r, 1_000));
  }
  throw new Error('Not confirmed within 30s: rebuild with a fresh blockhash and resend');
}

async function send(tx: VersionedTransaction): Promise<string> {
  const res = await fetch(`${SENDER}/fast`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      jsonrpc: '2.0',
      id: Date.now().toString(),
      method: 'sendTransaction',
      params: [
        Buffer.from(tx.serialize()).toString('base64'),
        { encoding: 'base64', skipPreflight: true, maxRetries: 0 }
      ]
    })
  });
  const json = await res.json();
  if (json.error) throw new Error(json.error.message);
  return json.result;
}
```

`maxRetries: 0`を使用すると、再確認ポリシーを所有できます：確認がタイムアウトした場合、古いトランザクションを再送信する代わりに、新しいブロックハッシュと再計算された手数料で再構築します。

デフォルトのスループットは50 TPSです。プロフェッショナルプランで[より高い制限をリクエスト](https://www.helius.dev/contact)できます。

## オプション：サンドイッチ攻撃者を回避するルート

サンドイッチ攻撃と統計的にリンクされたバリデーターを回避するために、エンドポイントURLに`?mev-protect=true`を追加します。リクエスト本文は変更されず、両方のティアで機能します：

```text theme={"system"}
http://ewr-sender.helius-rpc.com/fast?mev-protect=true
```

トレードオフについては[MEV Protect](/docs/ja/sending-transactions/mev-protect)をご覧ください。アトミックマルチトランザクション実行（最大4トランザクション、オールオアナッシング）には、同じエンドポイントで[`sendBundle`](/docs/ja/sending-transactions/sender-max#バンドル)を使用します。

## 関連ガイド

<CardGroup cols={2}>
  <Card title="Sender概要" icon="paper-plane" href="/docs/ja/sending-transactions/sender">
    ティア、エンドポイント、チップアカウント、レート制限について
  </Card>

  <Card title="事前確認での取引" icon="stopwatch" href="/docs/ja/pre-confirmations/guides/trade-on-preconfirmations">
    最速の送信経路を最速のトランザクション信号と組み合わせる
  </Card>
</CardGroup>
