メインコンテンツへスキップ
この購入をExit Intelligence Streamで追跡する予定の場合、購入トランザクションを送信する前にストリームを接続する必要があります。ストリームはオンチェーンのトークン到着をリアルタイムで観察して新しいポジションを検出します。購入がランディングしたときにストリームが接続されていない場合、ポジションは追跡されず、エグジットシグナルは生成されません。

エンドポイント

POST https://api.lasersell.io/v1/buy

ヘッダー

ヘッダー必須説明
Content-Typeはいapplication/jsonである必要があります
x-api-keyはいLaserSell APIキー

リクエストボディ: BuildBuyTxRequest

フィールド必須説明
mintstringはい購入するトークンミントアドレス(base58)。
user_pubkeystringはいウォレット公開鍵(base58)。
amountnumberいいえ*使用する人間可読金額(例: SOLの場合0.1、USD1の場合10.0)。amount_in_totalと排他的。
amount_in_totalnumberいいえ*入力アセットのatomic unitsでの使用金額(例: SOLの場合lamport)。amountと排他的。
slippage_bpsnumberはいベーシスポイントでの最大スリッページ許容値(例: 2000 = 20%)。
inputstringいいえ入力アセット: "SOL"(デフォルト)または"USD1"
modestringいいえルーティングモードヒント。有効値: "fast""secure"。デフォルト: "fast"
send_modestringいいえトランザクション送信モード: "helius_sender""astralane"、または"rpc"
tip_lamportsnumberいいえlamportでのオプションの優先度手数料チップ。
partner_fee_recipientstringいいえパートナーフィー受取ウォレット(base58 pubkey)。
partner_fee_bpsnumberいいえベーシスポイントでのパートナーフィー(最大50 = 0.5%)。partner_fee_lamportsと排他的。
partner_fee_lamportsnumberいいえフラットSOL lamportでのパートナーフィー(最大50,000,000)。partner_fee_bpsと排他的。
* amountまたはamount_in_totalのいずれか1つのみを指定する必要があります。amountinputアセットに基づいてatomic unitsに自動変換されます(SOL: 10^9、USD1: 10^6)。

レスポンス: BuildTxResponse

フィールド説明
txstringBase64エンコードされた未署名Solana VersionedTransaction
routeobjectオプションのルーティングメタデータ。
debugobjectオプションのデバッグ情報。

curl例

人間可読なamountを使用:
curl -X POST https://api.lasersell.io/v1/buy \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "mint": "TOKEN_MINT_ADDRESS",
    "user_pubkey": "YOUR_WALLET_PUBKEY",
    "amount": 0.1,
    "slippage_bps": 2000,
    "input": "SOL"
  }'
atomic amount_in_totalを使用:
curl -X POST https://api.lasersell.io/v1/buy \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d '{
    "mint": "TOKEN_MINT_ADDRESS",
    "user_pubkey": "YOUR_WALLET_PUBKEY",
    "amount_in_total": 100000000,
    "slippage_bps": 2000,
    "input": "SOL"
  }'

SDK例

import { ExitApiClient, type BuildBuyTxRequest } from "@lasersell/lasersell-sdk";

const client = ExitApiClient.withApiKey("YOUR_API_KEY");

const request: BuildBuyTxRequest = {
  mint: "TOKEN_MINT_ADDRESS",
  user_pubkey: "YOUR_WALLET_PUBKEY",
  amount: 0.1, // 0.1 SOL
  slippage_bps: 2_000,
};

const response = await client.buildBuyTx(request);
console.log("Unsigned tx (base64):", response.tx);

エラーレスポンス

完全なエラーエンベロープ仕様とリトライ可能なエラーロジックについてはエラー処理を参照してください。