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


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

    res = compass_api.safe.safe_batched_operations(chain=models.BatchedSafeOperationsRequestChain.BASE, sender="<value>", operations=[
        models.UserOperation(
            body=models.SetAllowanceParams(
                token="USDC",
                contract=models.SetAllowanceParamsContractEnum.AAVE_V3_POOL,
                amount="10",
            ),
        ),
        models.UserOperation(
            body=models.AaveSupplyParams(
                token="USDC",
                amount="10",
            ),
        ),
    ], estimate_gas=True)

    # Handle response
    print(res)
{
  "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

Request model for generating EIP-712 typed data for batched Safe transactions.

This endpoint accepts a list of DeFi operations and returns typed data that can be signed by the Safe owner. The signature can then be used in a subsequent call to execute the batched transaction.

chain
enum<string>
required
Available options:
arbitrum,
base,
ethereum
sender
string
required

The address of the transaction sender.

Examples:

"0x29F20a192328eF1aD35e1564aBFf4Be9C5ce5f7B"

operations
UserOperation · object[]
required

List of DeFi operations to batch into a single Safe transaction

Examples:
[
{
"body": {
"action_type": "SET_ALLOWANCE",
"amount": "10",
"contract": "AaveV3Pool",
"token": "USDC"
}
},
{
"body": {
"action_type": "AAVE_SUPPLY",
"amount": "10",
"token": "USDC"
}
}
]
estimate_gas
boolean
default:true

Determines whether to estimate gas costs for transactions, also verifying that the transaction can be successfully executed.

Response

Successful Response

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

domain
object
required

EIP-712 domain separator

types
object
required

EIP-712 type definitions

primaryType
string
required

Primary type for the structured data

Allowed value: "SafeTx"
message
object
required

Safe transaction message data