Skip to main content
POST
/
v2
/
earn
/
transfer
Python (SDK)
from compass_api_sdk import CompassAPI, models


with CompassAPI(
    api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api:

    res = compass_api.earn.earn_transfer(owner="0x01E62835dd7F52173546A325294762143eE4a882", chain=models.Chain.BASE, token="USDC", amount="0.01", action=models.EarnTransferRequestAction.DEPOSIT, gas_sponsorship=False)

    # Handle response
    print(res)
{
  "transaction": {
    "chainId": "0x2105",
    "data": "0xa9059cbb0000000000000000000000006b90e8b4e3e971e74c1a47a3a20976377e2db4b10000000000000000000000000000000000000000000000000000000005f5e100",
    "from": "0x4A83b4413CF41C3244027e1590E35a0F48403F0c",
    "gas": "0x5208",
    "maxFeePerGas": "0x59682f00",
    "maxPriorityFeePerGas": "0x3b9aca00",
    "nonce": "0x5",
    "to": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    "value": "0x0"
  }
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json
owner
string
default:0x01E62835dd7F52173546A325294762143eE4a882
required

The owner's wallet address.

chain
enum<string>
default:base
required

Blockchain network

Available options:
base,
ethereum,
arbitrum
token
string
default:USDC
required

The token you would like to transfer.

Examples:

"USDC"

"WETH"

"0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8"

amount
default:0.01
required

The amount of 'token' to transfer.

Required range: x > 0
Example:

1.5

action
enum<string>
default:DEPOSIT
required

Whether you are depositing to or withdrawing from your earn account.

Available options:
DEPOSIT,
WITHDRAW
gas_sponsorship
boolean
default:false

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.

spender
string | null

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 Earn Account (Safe) address, allowing the transfer to be included in a bundle transaction where the Safe pulls the tokens itself.

recipient
string | null

Optional recipient address for withdrawals. When action is 'WITHDRAW': - If provided, tokens will be sent to this address instead of the owner. - If not provided, defaults to the owner's address.

Response

Successful Response

transaction
UnsignedTransaction · object

Unsigned transaction for direct execution. Present when gas_sponsorship=false.

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

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

Example:
{
"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" }
]
}
}