POST
/
v0
/
multicall
/
execute

from compassapisdk import CompassAPISDK, models
from eth_account import Account
PRIVATE_KEY = "<YOUR_PRIVATE_KEY_HERE>"

with CompassAPISDK(
    api_key_auth="<YOUR_API_KEY_HERE>",
) as compass_api_sdk:
    # First get the authorization
    account = Account.from_key(PRIVATE_KEY)
    auth = compass_api_sdk.transaction_batching.authorization(
        chain=models.Chain.ETHEREUM_MAINNET,
        sender=account.address
    )
    
    # Sign the authorization
    signed_auth = Account.sign_authorization(auth, PRIVATE_KEY)

    # Then execute with the authorization
    res = compass_api_sdk.transaction_batching.execute(
        chain=models.Chain.ETHEREUM_MAINNET,
        sender=account.address,
        signed_authorization=signed_auth.recursive_model_dump(),
        actions=[
            models.MulticallAction(
                action_type=models.MulticallActionType.UNISWAP_BUY_EXACTLY,
                body=models.UniswapBuyExactlyParams(
                    token_in=models.TokenEnum.WETH,
                    token_out=models.TokenEnum.USDC,
                    fee=models.FeeEnum.ZERO_DOT_01,
                    amount_out=1.5,
                    amount_in_maximum=1.6,
                    wrap_eth=True,
                ),
            ),
            ...
        ])

    # Handle response
    print(res)
{
  "chainId": 123,
  "data": "<string>",
  "from": "<string>",
  "gas": 123,
  "to": "<string>",
  "value": 123,
  "nonce": 123,
  "maxFeePerGas": 123,
  "maxPriorityFeePerGas": 123,
  "authorizationList": []
}

Authorizations

x-api-key
string
header
required

Your Compass API Key. Get your key here.

Body

application/json

Request model for executing a multicall.

Response

200
application/json

Successful Response

The response is of type object.