from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.gas_sponsorship.gas_sponsorship_approve_transfer(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.Chain.BASE, token="USDT", gas_sponsorship=False)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.gasSponsorship.gasSponsorshipApproveTransfer({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
chain: "base",
token: "USDT",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/gas_sponsorship/approve_transfer \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"chain": "base",
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"token": "USDT"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chain: 'base',
owner: '0x06A9aF046187895AcFc7258450B15397CAc67400',
token: 'USDT'
})
};
fetch('https://api.compasslabs.ai/v2/gas_sponsorship/approve_transfer', 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.compasslabs.ai/v2/gas_sponsorship/approve_transfer",
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([
'chain' => 'base',
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'token' => 'USDT'
]),
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.compasslabs.ai/v2/gas_sponsorship/approve_transfer"
payload := strings.NewReader("{\n \"chain\": \"base\",\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"token\": \"USDT\"\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.compasslabs.ai/v2/gas_sponsorship/approve_transfer")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"chain\": \"base\",\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"token\": \"USDT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/gas_sponsorship/approve_transfer")
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 \"chain\": \"base\",\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"token\": \"USDT\"\n}"
response = http.request(request)
puts response.read_body{
"eip_712": {
"domain": {
"chainId": 8453,
"name": "USD Coin",
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"version": "2"
},
"message": {
"deadline": "1735689600",
"nonce": "0",
"owner": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"spender": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"value": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
"primaryType": "Permit",
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Permit": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Approve token transfer
Set up a one-time Permit2 allowance for gas-sponsored token transfers.
Required when using /earn/transfer or /credit/transfer with gas_sponsorship=true. This allowance only needs to be set up once per token.
With gas sponsorship (gas_sponsorship=true):
- Returns EIP-712 typed data for the owner to sign off-chain
- Submit signature + typed data to /prepare
- Only works for tokens that support EIP-2612 permit (e.g., USDC)
Some tokens, like USDT and WETH, do not support EIP-2612 permit. For these tokens, set gas_sponsorship=false to receive an unsigned transaction that the owner must sign, submit, and pay gas for.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.gas_sponsorship.gas_sponsorship_approve_transfer(owner="0x06A9aF046187895AcFc7258450B15397CAc67400", chain=models.Chain.BASE, token="USDT", gas_sponsorship=False)
# Handle response
print(res)import { CompassApiSDK } from "@compass-labs/api-sdk";
const compassApiSDK = new CompassApiSDK({
apiKeyAuth: "<YOUR_API_KEY_HERE>",
});
async function run() {
const result = await compassApiSDK.gasSponsorship.gasSponsorshipApproveTransfer({
owner: "0x06A9aF046187895AcFc7258450B15397CAc67400",
chain: "base",
token: "USDT",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/gas_sponsorship/approve_transfer \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"chain": "base",
"owner": "0x06A9aF046187895AcFc7258450B15397CAc67400",
"token": "USDT"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
chain: 'base',
owner: '0x06A9aF046187895AcFc7258450B15397CAc67400',
token: 'USDT'
})
};
fetch('https://api.compasslabs.ai/v2/gas_sponsorship/approve_transfer', 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.compasslabs.ai/v2/gas_sponsorship/approve_transfer",
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([
'chain' => 'base',
'owner' => '0x06A9aF046187895AcFc7258450B15397CAc67400',
'token' => 'USDT'
]),
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.compasslabs.ai/v2/gas_sponsorship/approve_transfer"
payload := strings.NewReader("{\n \"chain\": \"base\",\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"token\": \"USDT\"\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.compasslabs.ai/v2/gas_sponsorship/approve_transfer")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"chain\": \"base\",\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"token\": \"USDT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/gas_sponsorship/approve_transfer")
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 \"chain\": \"base\",\n \"owner\": \"0x06A9aF046187895AcFc7258450B15397CAc67400\",\n \"token\": \"USDT\"\n}"
response = http.request(request)
puts response.read_body{
"eip_712": {
"domain": {
"chainId": 8453,
"name": "USD Coin",
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"version": "2"
},
"message": {
"deadline": "1735689600",
"nonce": "0",
"owner": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"spender": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
"value": "115792089237316195423570985008687907853269984665640564039457584007913129639935"
},
"primaryType": "Permit",
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Permit": [
{
"name": "owner",
"type": "address"
},
{
"name": "spender",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "nonce",
"type": "uint256"
},
{
"name": "deadline",
"type": "uint256"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
The wallet address that owns the Earn Account.
"0x06A9aF046187895AcFc7258450B15397CAc67400"
Blockchain network
base, ethereum, arbitrum, hyperevm, tempo, bsc, ethereum_sepolia "base"
The token you would like to transfer with gas sponsorship.
"USDC"
"WETH"
"0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8"
Optionally request gas sponsorship. If set to true, EIP-712 signature data will be returned that must be signed by the owner and submitted to the /gas_sponsorship/prepare endpoint.
Response
Successful Response
Unsigned approval transaction. Present when gas_sponsorship=false.
Show child attributes
Show child attributes
{
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
}
EIP-712 typed data for off-chain permit signing. Present when gas_sponsorship=true.
Show child attributes
Show child attributes
{
"domain": {
"chainId": 8453,
"name": "USD Coin",
"verifyingContract": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"version": "2"
},
"message": {
"deadline": "1735689600",
"nonce": "0",
"owner": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"spender": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1",
"value": "100000000"
},
"primaryType": "Permit",
"types": {
"EIP712Domain": [
{ "name": "name", "type": "string" },
{ "name": "version", "type": "string" },
{ "name": "chainId", "type": "uint256" },
{
"name": "verifyingContract",
"type": "address"
}
],
"Permit": [
{ "name": "owner", "type": "address" },
{ "name": "spender", "type": "address" },
{ "name": "value", "type": "uint256" },
{ "name": "nonce", "type": "uint256" },
{ "name": "deadline", "type": "uint256" }
]
}
}
Was this page helpful?