構建交換交易(固定輸出)
curl --request POST \
--url https://transaction-v1.raydium.io/transaction/swap-base-out \
--header 'Content-Type: application/json' \
--data '
{
"wallet": "11111111111111111111111111111111",
"swapResponse": {
"id": "<string>",
"success": true,
"version": "<string>",
"data": {}
},
"txVersion": "V0",
"computeUnitPriceMicroLamports": "1000",
"wrapSol": false,
"unwrapSol": false,
"inputAccount": "TokenAccount1111111111111111111111111111111111",
"outputAccount": "TokenAccount2222222222222222222222222222222222",
"jitoInfo": {
"address": "<string>",
"amount": "<string>"
},
"referrerWallet": "ReferrerWallet1111111111111111111111111111111111"
}
'import requests
url = "https://transaction-v1.raydium.io/transaction/swap-base-out"
payload = {
"wallet": "11111111111111111111111111111111",
"swapResponse": {
"id": "<string>",
"success": True,
"version": "<string>",
"data": {}
},
"txVersion": "V0",
"computeUnitPriceMicroLamports": "1000",
"wrapSol": False,
"unwrapSol": False,
"inputAccount": "TokenAccount1111111111111111111111111111111111",
"outputAccount": "TokenAccount2222222222222222222222222222222222",
"jitoInfo": {
"address": "<string>",
"amount": "<string>"
},
"referrerWallet": "ReferrerWallet1111111111111111111111111111111111"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
wallet: '11111111111111111111111111111111',
swapResponse: {id: '<string>', success: true, version: '<string>', data: {}},
txVersion: 'V0',
computeUnitPriceMicroLamports: '1000',
wrapSol: false,
unwrapSol: false,
inputAccount: 'TokenAccount1111111111111111111111111111111111',
outputAccount: 'TokenAccount2222222222222222222222222222222222',
jitoInfo: {address: '<string>', amount: '<string>'},
referrerWallet: 'ReferrerWallet1111111111111111111111111111111111'
})
};
fetch('https://transaction-v1.raydium.io/transaction/swap-base-out', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://transaction-v1.raydium.io/transaction/swap-base-out",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'wallet' => '11111111111111111111111111111111',
'swapResponse' => [
'id' => '<string>',
'success' => true,
'version' => '<string>',
'data' => [
]
],
'txVersion' => 'V0',
'computeUnitPriceMicroLamports' => '1000',
'wrapSol' => false,
'unwrapSol' => false,
'inputAccount' => 'TokenAccount1111111111111111111111111111111111',
'outputAccount' => 'TokenAccount2222222222222222222222222222222222',
'jitoInfo' => [
'address' => '<string>',
'amount' => '<string>'
],
'referrerWallet' => 'ReferrerWallet1111111111111111111111111111111111'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://transaction-v1.raydium.io/transaction/swap-base-out"
payload := strings.NewReader("{\n \"wallet\": \"11111111111111111111111111111111\",\n \"swapResponse\": {\n \"id\": \"<string>\",\n \"success\": true,\n \"version\": \"<string>\",\n \"data\": {}\n },\n \"txVersion\": \"V0\",\n \"computeUnitPriceMicroLamports\": \"1000\",\n \"wrapSol\": false,\n \"unwrapSol\": false,\n \"inputAccount\": \"TokenAccount1111111111111111111111111111111111\",\n \"outputAccount\": \"TokenAccount2222222222222222222222222222222222\",\n \"jitoInfo\": {\n \"address\": \"<string>\",\n \"amount\": \"<string>\"\n },\n \"referrerWallet\": \"ReferrerWallet1111111111111111111111111111111111\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://transaction-v1.raydium.io/transaction/swap-base-out")
.header("Content-Type", "application/json")
.body("{\n \"wallet\": \"11111111111111111111111111111111\",\n \"swapResponse\": {\n \"id\": \"<string>\",\n \"success\": true,\n \"version\": \"<string>\",\n \"data\": {}\n },\n \"txVersion\": \"V0\",\n \"computeUnitPriceMicroLamports\": \"1000\",\n \"wrapSol\": false,\n \"unwrapSol\": false,\n \"inputAccount\": \"TokenAccount1111111111111111111111111111111111\",\n \"outputAccount\": \"TokenAccount2222222222222222222222222222222222\",\n \"jitoInfo\": {\n \"address\": \"<string>\",\n \"amount\": \"<string>\"\n },\n \"referrerWallet\": \"ReferrerWallet1111111111111111111111111111111111\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://transaction-v1.raydium.io/transaction/swap-base-out")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"wallet\": \"11111111111111111111111111111111\",\n \"swapResponse\": {\n \"id\": \"<string>\",\n \"success\": true,\n \"version\": \"<string>\",\n \"data\": {}\n },\n \"txVersion\": \"V0\",\n \"computeUnitPriceMicroLamports\": \"1000\",\n \"wrapSol\": false,\n \"unwrapSol\": false,\n \"inputAccount\": \"TokenAccount1111111111111111111111111111111111\",\n \"outputAccount\": \"TokenAccount2222222222222222222222222222222222\",\n \"jitoInfo\": {\n \"address\": \"<string>\",\n \"amount\": \"<string>\"\n },\n \"referrerWallet\": \"ReferrerWallet1111111111111111111111111111111111\"\n}"
response = http.request(request)
puts response.read_body{
"id": "550e8400-e29b-41d4-a716-446655440000",
"success": true,
"version": "V1",
"data": {
"transaction": "<string>",
"addressLookupTableAddresses": [
"<string>"
]
}
}{
"id": "<string>",
"success": false,
"version": "V1",
"msg": "<string>"
}Transaction
構建交換交易(固定輸出)
為所需輸出金額生成序列化的交換交易。
需要從 /compute/swap-base-out 獲得成功的計算回應。
POST
/
transaction
/
swap-base-out
構建交換交易(固定輸出)
curl --request POST \
--url https://transaction-v1.raydium.io/transaction/swap-base-out \
--header 'Content-Type: application/json' \
--data '
{
"wallet": "11111111111111111111111111111111",
"swapResponse": {
"id": "<string>",
"success": true,
"version": "<string>",
"data": {}
},
"txVersion": "V0",
"computeUnitPriceMicroLamports": "1000",
"wrapSol": false,
"unwrapSol": false,
"inputAccount": "TokenAccount1111111111111111111111111111111111",
"outputAccount": "TokenAccount2222222222222222222222222222222222",
"jitoInfo": {
"address": "<string>",
"amount": "<string>"
},
"referrerWallet": "ReferrerWallet1111111111111111111111111111111111"
}
'import requests
url = "https://transaction-v1.raydium.io/transaction/swap-base-out"
payload = {
"wallet": "11111111111111111111111111111111",
"swapResponse": {
"id": "<string>",
"success": True,
"version": "<string>",
"data": {}
},
"txVersion": "V0",
"computeUnitPriceMicroLamports": "1000",
"wrapSol": False,
"unwrapSol": False,
"inputAccount": "TokenAccount1111111111111111111111111111111111",
"outputAccount": "TokenAccount2222222222222222222222222222222222",
"jitoInfo": {
"address": "<string>",
"amount": "<string>"
},
"referrerWallet": "ReferrerWallet1111111111111111111111111111111111"
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
wallet: '11111111111111111111111111111111',
swapResponse: {id: '<string>', success: true, version: '<string>', data: {}},
txVersion: 'V0',
computeUnitPriceMicroLamports: '1000',
wrapSol: false,
unwrapSol: false,
inputAccount: 'TokenAccount1111111111111111111111111111111111',
outputAccount: 'TokenAccount2222222222222222222222222222222222',
jitoInfo: {address: '<string>', amount: '<string>'},
referrerWallet: 'ReferrerWallet1111111111111111111111111111111111'
})
};
fetch('https://transaction-v1.raydium.io/transaction/swap-base-out', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://transaction-v1.raydium.io/transaction/swap-base-out",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'wallet' => '11111111111111111111111111111111',
'swapResponse' => [
'id' => '<string>',
'success' => true,
'version' => '<string>',
'data' => [
]
],
'txVersion' => 'V0',
'computeUnitPriceMicroLamports' => '1000',
'wrapSol' => false,
'unwrapSol' => false,
'inputAccount' => 'TokenAccount1111111111111111111111111111111111',
'outputAccount' => 'TokenAccount2222222222222222222222222222222222',
'jitoInfo' => [
'address' => '<string>',
'amount' => '<string>'
],
'referrerWallet' => 'ReferrerWallet1111111111111111111111111111111111'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://transaction-v1.raydium.io/transaction/swap-base-out"
payload := strings.NewReader("{\n \"wallet\": \"11111111111111111111111111111111\",\n \"swapResponse\": {\n \"id\": \"<string>\",\n \"success\": true,\n \"version\": \"<string>\",\n \"data\": {}\n },\n \"txVersion\": \"V0\",\n \"computeUnitPriceMicroLamports\": \"1000\",\n \"wrapSol\": false,\n \"unwrapSol\": false,\n \"inputAccount\": \"TokenAccount1111111111111111111111111111111111\",\n \"outputAccount\": \"TokenAccount2222222222222222222222222222222222\",\n \"jitoInfo\": {\n \"address\": \"<string>\",\n \"amount\": \"<string>\"\n },\n \"referrerWallet\": \"ReferrerWallet1111111111111111111111111111111111\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://transaction-v1.raydium.io/transaction/swap-base-out")
.header("Content-Type", "application/json")
.body("{\n \"wallet\": \"11111111111111111111111111111111\",\n \"swapResponse\": {\n \"id\": \"<string>\",\n \"success\": true,\n \"version\": \"<string>\",\n \"data\": {}\n },\n \"txVersion\": \"V0\",\n \"computeUnitPriceMicroLamports\": \"1000\",\n \"wrapSol\": false,\n \"unwrapSol\": false,\n \"inputAccount\": \"TokenAccount1111111111111111111111111111111111\",\n \"outputAccount\": \"TokenAccount2222222222222222222222222222222222\",\n \"jitoInfo\": {\n \"address\": \"<string>\",\n \"amount\": \"<string>\"\n },\n \"referrerWallet\": \"ReferrerWallet1111111111111111111111111111111111\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://transaction-v1.raydium.io/transaction/swap-base-out")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"wallet\": \"11111111111111111111111111111111\",\n \"swapResponse\": {\n \"id\": \"<string>\",\n \"success\": true,\n \"version\": \"<string>\",\n \"data\": {}\n },\n \"txVersion\": \"V0\",\n \"computeUnitPriceMicroLamports\": \"1000\",\n \"wrapSol\": false,\n \"unwrapSol\": false,\n \"inputAccount\": \"TokenAccount1111111111111111111111111111111111\",\n \"outputAccount\": \"TokenAccount2222222222222222222222222222222222\",\n \"jitoInfo\": {\n \"address\": \"<string>\",\n \"amount\": \"<string>\"\n },\n \"referrerWallet\": \"ReferrerWallet1111111111111111111111111111111111\"\n}"
response = http.request(request)
puts response.read_body{
"id": "550e8400-e29b-41d4-a716-446655440000",
"success": true,
"version": "V1",
"data": {
"transaction": "<string>",
"addressLookupTableAddresses": [
"<string>"
]
}
}{
"id": "<string>",
"success": false,
"version": "V1",
"msg": "<string>"
}主體
application/json
簽署者錢包位址 (base58)。
範例:
"11111111111111111111111111111111"
來自計算端點的完整回應物件。
Show child attributes
Show child attributes
Solana 交易版本。
可用選項:
V0, LEGACY 範例:
"V0"
微 lamports 計算單位價格(用於優先費用)。
範例:
"1000"
如果輸入為原生 SOL,是否包裝 SOL。
範例:
false
輸出是否解除包裝 WSOL 為 SOL。
範例:
false
輸入的選用代幣帳戶位址。如果不包裝 SOL 則為必填。
範例:
"TokenAccount1111111111111111111111111111111111"
輸出的選用代幣帳戶位址。
範例:
"TokenAccount2222222222222222222222222222222222"
Jito bundle 的選用參數(用於 MEV 保護)。
Show child attributes
Show child attributes
用於費用收集的選用推薦人錢包位址。
範例:
"ReferrerWallet1111111111111111111111111111111111"
⌘I

