from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.credit.credit_transfer(owner="0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6", chain=models.CreditTransferRequestChain.BASE, token="USDC", amount=100, action=models.CreditTransferRequestAction.DEPOSIT, 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.credit.creditTransfer({
owner: "0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6",
chain: "base",
token: "USDC",
amount: 100,
action: "DEPOSIT",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/credit/transfer \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6",
"chain": "base",
"token": "USDC",
"amount": 100,
"action": "DEPOSIT"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6',
chain: 'base',
token: 'USDC',
amount: 100,
action: 'DEPOSIT'
})
};
fetch('https://api.compasslabs.ai/v2/credit/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/credit/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([
'owner' => '0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6',
'chain' => 'base',
'token' => 'USDC',
'amount' => 100,
'action' => 'DEPOSIT'
]),
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/credit/transfer"
payload := strings.NewReader("{\n \"owner\": \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n \"chain\": \"base\",\n \"token\": \"USDC\",\n \"amount\": 100,\n \"action\": \"DEPOSIT\"\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/credit/transfer")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n \"chain\": \"base\",\n \"token\": \"USDC\",\n \"amount\": 100,\n \"action\": \"DEPOSIT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/credit/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 \"owner\": \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n \"chain\": \"base\",\n \"token\": \"USDC\",\n \"amount\": 100,\n \"action\": \"DEPOSIT\"\n}"
response = http.request(request)
puts response.read_body{
"transaction": {
"chainId": "0x2105",
"data": "0xa9059cbb000000000000000000000000...",
"from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
"gas": "0x30d40",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x5f5e100",
"nonce": "0x2c",
"to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"value": "0x0"
},
"eip_712": {
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
},
{
"name": "operation",
"type": "uint8"
},
{
"name": "safeTxGas",
"type": "uint256"
},
{
"name": "baseGas",
"type": "uint256"
},
{
"name": "gasPrice",
"type": "uint256"
},
{
"name": "gasToken",
"type": "address"
},
{
"name": "refundReceiver",
"type": "address"
},
{
"name": "nonce",
"type": "uint256"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Transfer tokens to/from Credit Account
Transfer tokens between the owner’s EOA and their Credit Account.
DEPOSIT (EOA → Credit Account):
- With
gas_sponsorship=true: returns Permit2 EIP-712 typed data to sign. The gas sponsor callspermitTransferFromto pull tokens (1 signature). - With
gas_sponsorship=false: returns an unsigned ERC-20 transfer transaction.
WITHDRAW (Credit Account → EOA):
- With
gas_sponsorship=true: returns SafeTx EIP-712 typed data to sign. The gas sponsor broadcasts theexecTransaction(1 signature). - With
gas_sponsorship=false: returns an unsignedexecTransaction.
from compass_api_sdk import CompassAPI, models
with CompassAPI(
api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:
res = compass_api.credit.credit_transfer(owner="0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6", chain=models.CreditTransferRequestChain.BASE, token="USDC", amount=100, action=models.CreditTransferRequestAction.DEPOSIT, 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.credit.creditTransfer({
owner: "0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6",
chain: "base",
token: "USDC",
amount: 100,
action: "DEPOSIT",
});
console.log(result);
}
run();curl --request POST \
--url https://api.compasslabs.ai/v2/credit/transfer \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"owner": "0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6",
"chain": "base",
"token": "USDC",
"amount": 100,
"action": "DEPOSIT"
}
'const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
owner: '0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6',
chain: 'base',
token: 'USDC',
amount: 100,
action: 'DEPOSIT'
})
};
fetch('https://api.compasslabs.ai/v2/credit/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/credit/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([
'owner' => '0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6',
'chain' => 'base',
'token' => 'USDC',
'amount' => 100,
'action' => 'DEPOSIT'
]),
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/credit/transfer"
payload := strings.NewReader("{\n \"owner\": \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n \"chain\": \"base\",\n \"token\": \"USDC\",\n \"amount\": 100,\n \"action\": \"DEPOSIT\"\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/credit/transfer")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"owner\": \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n \"chain\": \"base\",\n \"token\": \"USDC\",\n \"amount\": 100,\n \"action\": \"DEPOSIT\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.compasslabs.ai/v2/credit/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 \"owner\": \"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6\",\n \"chain\": \"base\",\n \"token\": \"USDC\",\n \"amount\": 100,\n \"action\": \"DEPOSIT\"\n}"
response = http.request(request)
puts response.read_body{
"transaction": {
"chainId": "0x2105",
"data": "0xa9059cbb000000000000000000000000...",
"from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10",
"gas": "0x30d40",
"maxFeePerGas": "0x3b9aca00",
"maxPriorityFeePerGas": "0x5f5e100",
"nonce": "0x2c",
"to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"value": "0x0"
},
"eip_712": {
"domain": {
"chainId": 8453,
"verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1"
},
"message": {
"baseGas": "0",
"data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020",
"gasPrice": "0",
"gasToken": "0x0000000000000000000000000000000000000000",
"nonce": "7",
"operation": 1,
"refundReceiver": "0x0000000000000000000000000000000000000000",
"safeTxGas": "0",
"to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA",
"value": "0"
},
"primaryType": "SafeTx",
"types": {
"EIP712Domain": [
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"SafeTx": [
{
"name": "to",
"type": "address"
},
{
"name": "value",
"type": "uint256"
},
{
"name": "data",
"type": "bytes"
},
{
"name": "operation",
"type": "uint8"
},
{
"name": "safeTxGas",
"type": "uint256"
},
{
"name": "baseGas",
"type": "uint256"
},
{
"name": "gasPrice",
"type": "uint256"
},
{
"name": "gasToken",
"type": "address"
},
{
"name": "refundReceiver",
"type": "address"
},
{
"name": "nonce",
"type": "uint256"
}
]
}
}
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Body
The owner's wallet address (EOA).
"0x4A83fec8c6A9A25Be28f3242a16dBaD0ab00f3a6"
Blockchain network.
arbitrum, base, bsc, ethereum, hyperevm, tempo "base"
The token to transfer.
"USDC"
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
The amount of tokens to transfer (in token units, not wei).
x > 0100
Whether you are depositing to or withdrawing from your credit account.
DEPOSIT, WITHDRAW "DEPOSIT"
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.
The address that will call Permit2's permitTransferFrom to execute the transfer. When action is 'DEPOSIT' and gas_sponsorship is true: - If provided, the signature will authorize this address (typically a gas sponsor) to pull tokens. - If not provided, defaults to the Credit Account (Safe) address, allowing the transfer to be included in a bundle transaction where the Safe pulls the tokens itself.
Response
Successful Response
Show child attributes
Show child attributes
{ "chainId": "0x2105", "data": "0xa9059cbb000000000000000000000000...", "from": "0xc98949522db2eE403d6c75E91DDEe875a824bB10", "gas": "0x30d40", "maxFeePerGas": "0x3b9aca00", "maxPriorityFeePerGas": "0x5f5e100", "nonce": "0x2c", "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", "value": "0x0" }
Response containing EIP-712 typed data for Safe transaction signing.
- BatchedSafeOperationsResponse
- Permit2TypedData
Show child attributes
Show child attributes
{ "domain": { "chainId": 8453, "verifyingContract": "0x6B90E8B4E3E971E74C1A47a3a20976377E2dB4b1" }, "message": { "baseGas": "0", "data": "0x8d80ff0a0000000000000000000000000000000000000000000000000000000000000020", "gasPrice": "0", "gasToken": "0x0000000000000000000000000000000000000000", "nonce": "7", "operation": 1, "refundReceiver": "0x0000000000000000000000000000000000000000", "safeTxGas": "0", "to": "0x93C23AAE4793C14D6DF35D2A2A2234204e1559dA", "value": "0" }, "primaryType": "SafeTx", "types": { "EIP712Domain": [ { "name": "chainId", "type": "uint256" }, { "name": "verifyingContract", "type": "address" } ], "SafeTx": [ { "name": "to", "type": "address" }, { "name": "value", "type": "uint256" }, { "name": "data", "type": "bytes" }, { "name": "operation", "type": "uint8" }, { "name": "safeTxGas", "type": "uint256" }, { "name": "baseGas", "type": "uint256" }, { "name": "gasPrice", "type": "uint256" }, { "name": "gasToken", "type": "address" }, { "name": "refundReceiver", "type": "address" }, { "name": "nonce", "type": "uint256" } ] } }
Was this page helpful?