Sponsor Transaction
curl --request POST \
--url https://api.example.com/v1/sponsor \
--header 'Content-Type: application/json' \
--data '
{
"transaction": "<string>",
"network": "<string>"
}
'import requests
url = "https://api.example.com/v1/sponsor"
payload = {
"transaction": "<string>",
"network": "<string>"
}
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({transaction: '<string>', network: '<string>'})
};
fetch('https://api.example.com/v1/sponsor', 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://api.example.com/v1/sponsor",
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([
'transaction' => '<string>',
'network' => '<string>'
]),
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://api.example.com/v1/sponsor"
payload := strings.NewReader("{\n \"transaction\": \"<string>\",\n \"network\": \"<string>\"\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://api.example.com/v1/sponsor")
.header("Content-Type", "application/json")
.body("{\n \"transaction\": \"<string>\",\n \"network\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/sponsor")
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 \"transaction\": \"<string>\",\n \"network\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"hash": "<string>",
"feePaid": "<string>",
"ledger": 123,
"resultXdr": "<string>"
}API Reference
Sponsor Transaction
Submit a transaction for sponsorship and submission.
POST
/
v1
/
sponsor
Sponsor Transaction
curl --request POST \
--url https://api.example.com/v1/sponsor \
--header 'Content-Type: application/json' \
--data '
{
"transaction": "<string>",
"network": "<string>"
}
'import requests
url = "https://api.example.com/v1/sponsor"
payload = {
"transaction": "<string>",
"network": "<string>"
}
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({transaction: '<string>', network: '<string>'})
};
fetch('https://api.example.com/v1/sponsor', 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://api.example.com/v1/sponsor",
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([
'transaction' => '<string>',
'network' => '<string>'
]),
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://api.example.com/v1/sponsor"
payload := strings.NewReader("{\n \"transaction\": \"<string>\",\n \"network\": \"<string>\"\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://api.example.com/v1/sponsor")
.header("Content-Type", "application/json")
.body("{\n \"transaction\": \"<string>\",\n \"network\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/sponsor")
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 \"transaction\": \"<string>\",\n \"network\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"hash": "<string>",
"feePaid": "<string>",
"ledger": 123,
"resultXdr": "<string>"
}Wraps the provided transaction XDR in a fee-bump envelope and submits it to the Stellar network.
View on GitHub
Request Body
string
required
The base64-encoded XDR of the signed transaction or fee-bump transaction to sponsor.
string
required
The target network. Must be either
testnet or mainnet.Response Fields
string
The transaction hash generated by the Stellar network.
string
The total network fee paid by the relay in stroops.
number
The sequence number of the ledger that included the transaction.
string
The base64-encoded result XDR returned by the network.
Error Codes
| Code | Description |
|---|---|
VALIDATION_ERROR | The provided XDR is malformed or invalid. |
INSUFFICIENT_CREDITS | Your project balance is too low to cover the fee. |
SUBMISSION_FAILED | The network rejected the transaction (e.g., tx_bad_seq). |
RATE_LIMIT_EXCEEDED | You have exceeded your project’s rate limit. |
SDK Example
import { Grat } from '@grat-official-sdk/sdk';
const grat = Grat.testnet();
const result = await grat.sponsor(transaction);
console.log(result.hash);
⌘I