curl --request POST \
--url https://api.ternswap.xyz/v1/quotes/{id}/submit \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"call": {
"contractAddress": "0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a",
"entrypoint": "apply_actions",
"calldata": [
"0x4",
"0x1"
]
},
"proof": "AAAAAQ…",
"proofFacts": [
"0x50524f4f4632",
"0x5649525455414c5f534e4f53"
]
}
'import requests
url = "https://api.ternswap.xyz/v1/quotes/{id}/submit"
payload = {
"call": {
"contractAddress": "0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a",
"entrypoint": "apply_actions",
"calldata": ["0x4", "0x1"]
},
"proof": "AAAAAQ…",
"proofFacts": ["0x50524f4f4632", "0x5649525455414c5f534e4f53"]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
call: {
contractAddress: '0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a',
entrypoint: 'apply_actions',
calldata: ['0x4', '0x1']
},
proof: 'AAAAAQ…',
proofFacts: ['0x50524f4f4632', '0x5649525455414c5f534e4f53']
})
};
fetch('https://api.ternswap.xyz/v1/quotes/{id}/submit', 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.ternswap.xyz/v1/quotes/{id}/submit",
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([
'call' => [
'contractAddress' => '0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a',
'entrypoint' => 'apply_actions',
'calldata' => [
'0x4',
'0x1'
]
],
'proof' => 'AAAAAQ…',
'proofFacts' => [
'0x50524f4f4632',
'0x5649525455414c5f534e4f53'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.ternswap.xyz/v1/quotes/{id}/submit"
payload := strings.NewReader("{\n \"call\": {\n \"contractAddress\": \"0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a\",\n \"entrypoint\": \"apply_actions\",\n \"calldata\": [\n \"0x4\",\n \"0x1\"\n ]\n },\n \"proof\": \"AAAAAQ…\",\n \"proofFacts\": [\n \"0x50524f4f4632\",\n \"0x5649525455414c5f534e4f53\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.ternswap.xyz/v1/quotes/{id}/submit")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"call\": {\n \"contractAddress\": \"0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a\",\n \"entrypoint\": \"apply_actions\",\n \"calldata\": [\n \"0x4\",\n \"0x1\"\n ]\n },\n \"proof\": \"AAAAAQ…\",\n \"proofFacts\": [\n \"0x50524f4f4632\",\n \"0x5649525455414c5f534e4f53\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ternswap.xyz/v1/quotes/{id}/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"call\": {\n \"contractAddress\": \"0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a\",\n \"entrypoint\": \"apply_actions\",\n \"calldata\": [\n \"0x4\",\n \"0x1\"\n ]\n },\n \"proof\": \"AAAAAQ…\",\n \"proofFacts\": [\n \"0x50524f4f4632\",\n \"0x5649525455414c5f534e4f53\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "q_01M63G8Z0K7W2YQ5VJ6E3R9T4N",
"status": "awaiting_deposit",
"route": "swap",
"from": {
"chain": "starknet",
"asset": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
"amount": "100000000000000000000",
"txHash": "0x3af816e76304424920bbc91c44cf34cfa46027593b01810ff19f8ed6819e8a8"
},
"to": {
"chain": "starknet",
"asset": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"amount": "13120000",
"minAmount": "13054400"
},
"fees": {
"totalUsd": "0.33",
"items": [
{
"kind": "protocol",
"usd": "0.03"
},
{
"kind": "privacy",
"usd": "0.30"
}
]
},
"etaSecs": 6,
"createdAt": 1793084854,
"expiresAt": 1793085154
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}Submit a private swap
Hands the private swap the user’s wallet proved (strk20PrepareInvoke over the quote’s execute.strk20) to Tern’s
relayer. The relayer simulates it with its proof and sends it only if it calls the pool’s apply_actions, pays the
relayer the quoted fee, and swaps for this quote; its account is the sender, so the user’s never appears. Submit
before expiresAt. The quote’s from.txHash is the relayer’s transaction as soon as it is signed.
curl --request POST \
--url https://api.ternswap.xyz/v1/quotes/{id}/submit \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"call": {
"contractAddress": "0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a",
"entrypoint": "apply_actions",
"calldata": [
"0x4",
"0x1"
]
},
"proof": "AAAAAQ…",
"proofFacts": [
"0x50524f4f4632",
"0x5649525455414c5f534e4f53"
]
}
'import requests
url = "https://api.ternswap.xyz/v1/quotes/{id}/submit"
payload = {
"call": {
"contractAddress": "0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a",
"entrypoint": "apply_actions",
"calldata": ["0x4", "0x1"]
},
"proof": "AAAAAQ…",
"proofFacts": ["0x50524f4f4632", "0x5649525455414c5f534e4f53"]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
call: {
contractAddress: '0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a',
entrypoint: 'apply_actions',
calldata: ['0x4', '0x1']
},
proof: 'AAAAAQ…',
proofFacts: ['0x50524f4f4632', '0x5649525455414c5f534e4f53']
})
};
fetch('https://api.ternswap.xyz/v1/quotes/{id}/submit', 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.ternswap.xyz/v1/quotes/{id}/submit",
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([
'call' => [
'contractAddress' => '0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a',
'entrypoint' => 'apply_actions',
'calldata' => [
'0x4',
'0x1'
]
],
'proof' => 'AAAAAQ…',
'proofFacts' => [
'0x50524f4f4632',
'0x5649525455414c5f534e4f53'
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-api-key: <api-key>"
],
]);
$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.ternswap.xyz/v1/quotes/{id}/submit"
payload := strings.NewReader("{\n \"call\": {\n \"contractAddress\": \"0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a\",\n \"entrypoint\": \"apply_actions\",\n \"calldata\": [\n \"0x4\",\n \"0x1\"\n ]\n },\n \"proof\": \"AAAAAQ…\",\n \"proofFacts\": [\n \"0x50524f4f4632\",\n \"0x5649525455414c5f534e4f53\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
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.ternswap.xyz/v1/quotes/{id}/submit")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"call\": {\n \"contractAddress\": \"0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a\",\n \"entrypoint\": \"apply_actions\",\n \"calldata\": [\n \"0x4\",\n \"0x1\"\n ]\n },\n \"proof\": \"AAAAAQ…\",\n \"proofFacts\": [\n \"0x50524f4f4632\",\n \"0x5649525455414c5f534e4f53\"\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.ternswap.xyz/v1/quotes/{id}/submit")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"call\": {\n \"contractAddress\": \"0x040337b1af3c663e86e333bab5a4b28da8d4652a15a69beee2b677776ffe812a\",\n \"entrypoint\": \"apply_actions\",\n \"calldata\": [\n \"0x4\",\n \"0x1\"\n ]\n },\n \"proof\": \"AAAAAQ…\",\n \"proofFacts\": [\n \"0x50524f4f4632\",\n \"0x5649525455414c5f534e4f53\"\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "q_01M63G8Z0K7W2YQ5VJ6E3R9T4N",
"status": "awaiting_deposit",
"route": "swap",
"from": {
"chain": "starknet",
"asset": "0x04718f5a0fc34cc1af16a1cdee98ffb20c31f5cd61d6ab07201858f4287c938d",
"amount": "100000000000000000000",
"txHash": "0x3af816e76304424920bbc91c44cf34cfa46027593b01810ff19f8ed6819e8a8"
},
"to": {
"chain": "starknet",
"asset": "0x053c91253bc9682c04929ca02ed00b3e423f6710d2ee7e0d5ebb06f3ecf368a8",
"amount": "13120000",
"minAmount": "13054400"
},
"fees": {
"totalUsd": "0.33",
"items": [
{
"kind": "protocol",
"usd": "0.03"
},
{
"kind": "privacy",
"usd": "0.30"
}
]
},
"etaSecs": 6,
"createdAt": 1793084854,
"expiresAt": 1793085154
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}{
"type": "https://docs.ternswap.xyz/api-reference/errors#no_route",
"title": "No route",
"status": 422,
"code": "invalid_request",
"detail": "no solver quoted this route",
"requestId": "01JC2W6Q0Z8V5K3M7N1P4R9T2X",
"errors": [
{
"pointer": "#/fromAmount",
"detail": "must be a positive base-10 integer"
}
]
}Authorizations
Headers
Body
The body of POST /v1/quotes/{id}/submit: a private swap's transaction as the wallet proved it
(strk20PrepareInvoke). Debug shows the proof's size only.
Response
The relayer sends the private swap; follow the quote
A firm quote: a solver's commitment (or a swap's route), and its progress. Every quote route and webhook returns this one object.