Transaction Batching
Execute Tx Batching
Transaction Batching
Execute Tx Batching
Execute a batch of transactions in a single multicall using EIP-7702.
This endpoint allows bundling multiple contract calls into a single atomic transaction, reducing gas costs and ensuring all operations succeed or fail together. The transaction must be authorized using the /authorization endpoint to prevent replay attacks.
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": []
}
Body
application/json
Request model for executing a multicall.
Response
200
application/json
Successful Response
The response is of type object
.
Was this page helpful?
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": []
}