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="0xE4780eeB4D345576dE762573cEA0F269b3099adE", chain=models.Chain.BASE, token="USDC", amount="0.01", action=models.EarnTransferRequestAction.FUND, gas_sponsorship=False)

    # Handle response
    print(res)
{
  "transaction": {
    "chainId": "<string>",
    "data": "<string>",
    "from": "<string>",
    "gas": "<string>",
    "to": "<string>",
    "value": "<string>",
    "nonce": "<string>",
    "maxFeePerGas": "<string>",
    "maxPriorityFeePerGas": "<string>"
  },
  "eip_712": {
    "domain": {
      "chainId": 123,
      "verifyingContract": "<string>"
    },
    "types": {
      "EIP712Domain": [
        {
          "name": "<string>",
          "type": "<string>"
        }
      ],
      "SafeTx": [
        {
          "name": "<string>",
          "type": "<string>"
        }
      ]
    },
    "primaryType": "<string>",
    "message": {
      "to": "<string>",
      "value": "<string>",
      "operation": 0,
      "safeTxGas": "<string>",
      "baseGas": "<string>",
      "gasPrice": "<string>",
      "gasToken": "<string>",
      "refundReceiver": "<string>",
      "nonce": "<string>"
    }
  }
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json
owner
string
required

The owner's wallet address.

chain
enum<string>
required

Blockchain network

Available options:
base,
ethereum,
arbitrum
token
string
required

The token you would like to transfer.

Examples:

"USDC"

"WETH"

"0xA0b86a33E6441ccF30EE5DdEF1E9b652C91ac1c8"

amount
required

The amount of 'token' to transfer.

Required range: x > 0
Examples:

1.5

action
enum<string>
required

Whether you are funding or withdrawing from your earn account.

Available options:
FUND,
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 /sponsor_gas endpoint.

spender
string | null

The address of the wallet which will send the transaction. This only needs to be set when 'action' is 'FUND' and gas_sponsorship is true.

Response

Successful Response

transaction
object | null
required
eip_712
object | null
required

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

  • BatchedSafeOperationsResponse
  • Permit2TypedData