Skip to main content
POST
/
v2
/
gas_sponsorship
/
prepare
Python (SDK)
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_prepare(owner="0xCE1A77F0abff993d6d3D04d44b70831c6924fb40", chain=models.Chain.ARBITRUM, eip_712={
        "domain": {
            "name": "USD Coin",
            "version": "2",
            "chain_id": 42161,
            "verifying_contract": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
        },
        "types": {
            "eip712_domain": [
                {
                    "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",
                },
            ],
        },
        "primary_type": "Permit",
        "message": {
            "owner": "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40",
            "spender": "0x000000000022D473030F116dDEE9F6B43aC78BA3",
            "value": "115792089237316195423570985008687907853269984665640564039457584007913129639935",
            "nonce": "0",
            "deadline": "1762269774",
        },
    }, signature="0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c", sender="0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d", product=models.Product.EARN)

    # 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.gasSponsorshipPrepare({
owner: "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40",
chain: "arbitrum",
eip712: {
domain: {
name: "USD Coin",
version: "2",
chainId: 42161,
verifyingContract: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
},
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",
},
],
},
primaryType: "Permit",
message: {
owner: "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40",
spender: "0x000000000022D473030F116dDEE9F6B43aC78BA3",
value: "115792089237316195423570985008687907853269984665640564039457584007913129639935",
nonce: "0",
deadline: "1762269774",
},
},
signature: "0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c",
sender: "0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d",
});

console.log(result);
}

run();
curl --request POST \
--url https://api.compasslabs.ai/v2/gas_sponsorship/prepare \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40",
"chain": "arbitrum",
"eip_712": {
"domain": {
"chainId": 42161,
"name": "USD Coin",
"verifyingContract": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"version": "2"
},
"message": {
"deadline": "1762269774",
"nonce": "0",
"owner": "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40",
"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"
}
]
}
},
"signature": "0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c",
"sender": "0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d"
}
'
const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '0xCE1A77F0abff993d6d3D04d44b70831c6924fb40',
chain: 'arbitrum',
eip_712: {
domain: {
chainId: 42161,
name: 'USD Coin',
verifyingContract: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
version: '2'
},
message: {
deadline: '1762269774',
nonce: '0',
owner: '0xCE1A77F0abff993d6d3D04d44b70831c6924fb40',
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'}
]
}
},
signature: '0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c',
sender: '0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d'
})
};

fetch('https://api.compasslabs.ai/v2/gas_sponsorship/prepare', 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/prepare",
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([
'owner' => '0xCE1A77F0abff993d6d3D04d44b70831c6924fb40',
'chain' => 'arbitrum',
'eip_712' => [
'domain' => [
'chainId' => 42161,
'name' => 'USD Coin',
'verifyingContract' => '0xaf88d065e77c8cC2239327C5EDb3A432268e5831',
'version' => '2'
],
'message' => [
'deadline' => '1762269774',
'nonce' => '0',
'owner' => '0xCE1A77F0abff993d6d3D04d44b70831c6924fb40',
'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'
]
]
]
],
'signature' => '0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c',
'sender' => '0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d'
]),
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/prepare"

payload := strings.NewReader("{\n \"owner\": \"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40\",\n \"chain\": \"arbitrum\",\n \"eip_712\": {\n \"domain\": {\n \"chainId\": 42161,\n \"name\": \"USD Coin\",\n \"verifyingContract\": \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\",\n \"version\": \"2\"\n },\n \"message\": {\n \"deadline\": \"1762269774\",\n \"nonce\": \"0\",\n \"owner\": \"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40\",\n \"spender\": \"0x000000000022D473030F116dDEE9F6B43aC78BA3\",\n \"value\": \"115792089237316195423570985008687907853269984665640564039457584007913129639935\"\n },\n \"primaryType\": \"Permit\",\n \"types\": {\n \"EIP712Domain\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"chainId\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"verifyingContract\",\n \"type\": \"address\"\n }\n ],\n \"Permit\": [\n {\n \"name\": \"owner\",\n \"type\": \"address\"\n },\n {\n \"name\": \"spender\",\n \"type\": \"address\"\n },\n {\n \"name\": \"value\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"nonce\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"deadline\",\n \"type\": \"uint256\"\n }\n ]\n }\n },\n \"signature\": \"0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c\",\n \"sender\": \"0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d\"\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/prepare")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40\",\n \"chain\": \"arbitrum\",\n \"eip_712\": {\n \"domain\": {\n \"chainId\": 42161,\n \"name\": \"USD Coin\",\n \"verifyingContract\": \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\",\n \"version\": \"2\"\n },\n \"message\": {\n \"deadline\": \"1762269774\",\n \"nonce\": \"0\",\n \"owner\": \"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40\",\n \"spender\": \"0x000000000022D473030F116dDEE9F6B43aC78BA3\",\n \"value\": \"115792089237316195423570985008687907853269984665640564039457584007913129639935\"\n },\n \"primaryType\": \"Permit\",\n \"types\": {\n \"EIP712Domain\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"chainId\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"verifyingContract\",\n \"type\": \"address\"\n }\n ],\n \"Permit\": [\n {\n \"name\": \"owner\",\n \"type\": \"address\"\n },\n {\n \"name\": \"spender\",\n \"type\": \"address\"\n },\n {\n \"name\": \"value\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"nonce\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"deadline\",\n \"type\": \"uint256\"\n }\n ]\n }\n },\n \"signature\": \"0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c\",\n \"sender\": \"0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.compasslabs.ai/v2/gas_sponsorship/prepare")

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 \"owner\": \"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40\",\n \"chain\": \"arbitrum\",\n \"eip_712\": {\n \"domain\": {\n \"chainId\": 42161,\n \"name\": \"USD Coin\",\n \"verifyingContract\": \"0xaf88d065e77c8cC2239327C5EDb3A432268e5831\",\n \"version\": \"2\"\n },\n \"message\": {\n \"deadline\": \"1762269774\",\n \"nonce\": \"0\",\n \"owner\": \"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40\",\n \"spender\": \"0x000000000022D473030F116dDEE9F6B43aC78BA3\",\n \"value\": \"115792089237316195423570985008687907853269984665640564039457584007913129639935\"\n },\n \"primaryType\": \"Permit\",\n \"types\": {\n \"EIP712Domain\": [\n {\n \"name\": \"name\",\n \"type\": \"string\"\n },\n {\n \"name\": \"version\",\n \"type\": \"string\"\n },\n {\n \"name\": \"chainId\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"verifyingContract\",\n \"type\": \"address\"\n }\n ],\n \"Permit\": [\n {\n \"name\": \"owner\",\n \"type\": \"address\"\n },\n {\n \"name\": \"spender\",\n \"type\": \"address\"\n },\n {\n \"name\": \"value\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"nonce\",\n \"type\": \"uint256\"\n },\n {\n \"name\": \"deadline\",\n \"type\": \"uint256\"\n }\n ]\n }\n },\n \"signature\": \"0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c\",\n \"sender\": \"0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d\"\n}"

response = http.request(request)
puts response.read_body
{
  "transaction": {
    "chainId": "0x2105",
    "data": "0x6a761202000000000000000000000000833589fcd6edb6e08f4c7c32d4f71b54bda029130000000000000000000000000000000000000000000000000000000005f5e100",
    "from": "0x7B3B1F28a30276A21bE8e68E4C829972c7e641E7",
    "gas": "0x7a120",
    "maxFeePerGas": "0x59682f00",
    "maxPriorityFeePerGas": "0x3b9aca00",
    "nonce": "0x12",
    "to": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1",
    "value": "0x0"
  }
}
{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json
owner
string
default:0xCE1A77F0abff993d6d3D04d44b70831c6924fb40
required

The wallet address that owns the Product Account.

Example:

"0xCE1A77F0abff993d6d3D04d44b70831c6924fb40"

chain
enum<string>
default:arbitrum
required

Blockchain network

Available options:
base,
ethereum,
arbitrum,
hyperevm,
tempo,
bsc
Example:

"arbitrum"

eip_712
BatchedSafeOperationsResponse · object
required

Response containing EIP-712 typed data for Safe transaction signing.

Example:
{
"domain": {
"chainId": 42161,
"name": "USD Coin",
"verifyingContract": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
"version": "2"
},
"message": {
"deadline": "1762269774",
"nonce": "0",
"owner": "0xCE1A77F0abff993d6d3D04d44b70831c6924fb40",
"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" }
]
}
}
signature
string
default:0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c
required

The EIP-712 signed typed data signature.

Example:

"0x160d2709ae195f591daa33ad6ab1fb18b8762a39d8c4466c4cbe95cf6881fc3d54d469710ef0e7fd64ecff47c1ba5741d7254903bfaebdacea5aa8289f81ba9a1c"

sender
string
default:0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d
required

The address of the wallet which will send the transaction.

Example:

"0x02122Ac49b0Be2e0eAD957F2D080805A0127Aa9d"

product
enum<string>
default:earn

Which product the gas sponsorship is for. Determines which Product Account (Safe) address to use.

Available options:
earn,
credit,
tokenized_assets

Response

Successful Response

transaction
UnsignedTransaction · object
required

Transaction to be signed & submitted via the sender to the network.

Example:
{
"chainId": "0x2105",
"data": "0x1688f0b900000000000000000000000029fcb43b46531bca003ddc8fcb67ffe91900c762000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000675f4a3d",
"from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
"gas": "0x7a120",
"maxFeePerGas": "0x59682f00",
"maxPriorityFeePerGas": "0x3b9aca00",
"nonce": "0x5",
"to": "0x4e1DCf7AD4e460CfD30791CCC4F9c8a4f820ec67",
"value": "0x0"
}