Create Sell Transaction
Generate a Base64 encoded sell transaction for a standard pool.
Flow: First call /quote/sell to get a quote, then pass the quote_response here to build the transaction. The returned transaction must be signed by the payer and submitted to the Solana network.
curl --request POST \
--url https://tx.api.heaven.xyz/tx/sell \
--header 'Content-Type: application/json' \
--data '
{
"encoded_user_defined_event_data": "custom_event_data",
"payer": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K",
"quote_response": {
"amount_in": 1,
"amount_in_ui": 123,
"config_version": 1,
"minimum_out": 1,
"minimum_out_ui": 123,
"mint": "<string>",
"program_id": "<string>",
"slippage_bps": 1
},
"compute_unit_limit": 200000,
"compute_unit_price": 40000000,
"source": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K"
}
'import requests
url = "https://tx.api.heaven.xyz/tx/sell"
payload = {
"encoded_user_defined_event_data": "custom_event_data",
"payer": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K",
"quote_response": {
"amount_in": 1,
"amount_in_ui": 123,
"config_version": 1,
"minimum_out": 1,
"minimum_out_ui": 123,
"mint": "<string>",
"program_id": "<string>",
"slippage_bps": 1
},
"compute_unit_limit": 200000,
"compute_unit_price": 40000000,
"source": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K"
}
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({
encoded_user_defined_event_data: 'custom_event_data',
payer: 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K',
quote_response: {
amount_in: 1,
amount_in_ui: 123,
config_version: 1,
minimum_out: 1,
minimum_out_ui: 123,
mint: '<string>',
program_id: '<string>',
slippage_bps: 1
},
compute_unit_limit: 200000,
compute_unit_price: 40000000,
source: 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K'
})
};
fetch('https://tx.api.heaven.xyz/tx/sell', 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://tx.api.heaven.xyz/tx/sell",
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([
'encoded_user_defined_event_data' => 'custom_event_data',
'payer' => 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K',
'quote_response' => [
'amount_in' => 1,
'amount_in_ui' => 123,
'config_version' => 1,
'minimum_out' => 1,
'minimum_out_ui' => 123,
'mint' => '<string>',
'program_id' => '<string>',
'slippage_bps' => 1
],
'compute_unit_limit' => 200000,
'compute_unit_price' => 40000000,
'source' => 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K'
]),
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://tx.api.heaven.xyz/tx/sell"
payload := strings.NewReader("{\n \"encoded_user_defined_event_data\": \"custom_event_data\",\n \"payer\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\",\n \"quote_response\": {\n \"amount_in\": 1,\n \"amount_in_ui\": 123,\n \"config_version\": 1,\n \"minimum_out\": 1,\n \"minimum_out_ui\": 123,\n \"mint\": \"<string>\",\n \"program_id\": \"<string>\",\n \"slippage_bps\": 1\n },\n \"compute_unit_limit\": 200000,\n \"compute_unit_price\": 40000000,\n \"source\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\"\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://tx.api.heaven.xyz/tx/sell")
.header("Content-Type", "application/json")
.body("{\n \"encoded_user_defined_event_data\": \"custom_event_data\",\n \"payer\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\",\n \"quote_response\": {\n \"amount_in\": 1,\n \"amount_in_ui\": 123,\n \"config_version\": 1,\n \"minimum_out\": 1,\n \"minimum_out_ui\": 123,\n \"mint\": \"<string>\",\n \"program_id\": \"<string>\",\n \"slippage_bps\": 1\n },\n \"compute_unit_limit\": 200000,\n \"compute_unit_price\": 40000000,\n \"source\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tx.api.heaven.xyz/tx/sell")
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 \"encoded_user_defined_event_data\": \"custom_event_data\",\n \"payer\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\",\n \"quote_response\": {\n \"amount_in\": 1,\n \"amount_in_ui\": 123,\n \"config_version\": 1,\n \"minimum_out\": 1,\n \"minimum_out_ui\": 123,\n \"mint\": \"<string>\",\n \"program_id\": \"<string>\",\n \"slippage_bps\": 1\n },\n \"compute_unit_limit\": 200000,\n \"compute_unit_price\": 40000000,\n \"source\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\"\n}"
response = http.request(request)
puts response.read_body{
"tx": "<string>"
}Body
Encoded user defined event data
"custom_event_data"
Payer of the transaction
"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K"
The full quote response object from the Quote Sell endpoint. Pass the entire response without modification.
Show child attributes
Show child attributes
Optional compute unit limit for the transaction
x >= 0200000
Optional compute unit price for the transaction
x >= 040000000
Optional source token account for the sell operation. If not provided, the payer's associated token account will be used.
"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K"
Response
Base64 encoded transaction
curl --request POST \
--url https://tx.api.heaven.xyz/tx/sell \
--header 'Content-Type: application/json' \
--data '
{
"encoded_user_defined_event_data": "custom_event_data",
"payer": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K",
"quote_response": {
"amount_in": 1,
"amount_in_ui": 123,
"config_version": 1,
"minimum_out": 1,
"minimum_out_ui": 123,
"mint": "<string>",
"program_id": "<string>",
"slippage_bps": 1
},
"compute_unit_limit": 200000,
"compute_unit_price": 40000000,
"source": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K"
}
'import requests
url = "https://tx.api.heaven.xyz/tx/sell"
payload = {
"encoded_user_defined_event_data": "custom_event_data",
"payer": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K",
"quote_response": {
"amount_in": 1,
"amount_in_ui": 123,
"config_version": 1,
"minimum_out": 1,
"minimum_out_ui": 123,
"mint": "<string>",
"program_id": "<string>",
"slippage_bps": 1
},
"compute_unit_limit": 200000,
"compute_unit_price": 40000000,
"source": "G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K"
}
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({
encoded_user_defined_event_data: 'custom_event_data',
payer: 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K',
quote_response: {
amount_in: 1,
amount_in_ui: 123,
config_version: 1,
minimum_out: 1,
minimum_out_ui: 123,
mint: '<string>',
program_id: '<string>',
slippage_bps: 1
},
compute_unit_limit: 200000,
compute_unit_price: 40000000,
source: 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K'
})
};
fetch('https://tx.api.heaven.xyz/tx/sell', 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://tx.api.heaven.xyz/tx/sell",
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([
'encoded_user_defined_event_data' => 'custom_event_data',
'payer' => 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K',
'quote_response' => [
'amount_in' => 1,
'amount_in_ui' => 123,
'config_version' => 1,
'minimum_out' => 1,
'minimum_out_ui' => 123,
'mint' => '<string>',
'program_id' => '<string>',
'slippage_bps' => 1
],
'compute_unit_limit' => 200000,
'compute_unit_price' => 40000000,
'source' => 'G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K'
]),
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://tx.api.heaven.xyz/tx/sell"
payload := strings.NewReader("{\n \"encoded_user_defined_event_data\": \"custom_event_data\",\n \"payer\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\",\n \"quote_response\": {\n \"amount_in\": 1,\n \"amount_in_ui\": 123,\n \"config_version\": 1,\n \"minimum_out\": 1,\n \"minimum_out_ui\": 123,\n \"mint\": \"<string>\",\n \"program_id\": \"<string>\",\n \"slippage_bps\": 1\n },\n \"compute_unit_limit\": 200000,\n \"compute_unit_price\": 40000000,\n \"source\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\"\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://tx.api.heaven.xyz/tx/sell")
.header("Content-Type", "application/json")
.body("{\n \"encoded_user_defined_event_data\": \"custom_event_data\",\n \"payer\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\",\n \"quote_response\": {\n \"amount_in\": 1,\n \"amount_in_ui\": 123,\n \"config_version\": 1,\n \"minimum_out\": 1,\n \"minimum_out_ui\": 123,\n \"mint\": \"<string>\",\n \"program_id\": \"<string>\",\n \"slippage_bps\": 1\n },\n \"compute_unit_limit\": 200000,\n \"compute_unit_price\": 40000000,\n \"source\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://tx.api.heaven.xyz/tx/sell")
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 \"encoded_user_defined_event_data\": \"custom_event_data\",\n \"payer\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\",\n \"quote_response\": {\n \"amount_in\": 1,\n \"amount_in_ui\": 123,\n \"config_version\": 1,\n \"minimum_out\": 1,\n \"minimum_out_ui\": 123,\n \"mint\": \"<string>\",\n \"program_id\": \"<string>\",\n \"slippage_bps\": 1\n },\n \"compute_unit_limit\": 200000,\n \"compute_unit_price\": 40000000,\n \"source\": \"G2pX3b4Y8m7v5xX9L5f6y7z8A9B0C1D2E3F4G5H6I7J8K\"\n}"
response = http.request(request)
puts response.read_body{
"tx": "<string>"
}