- Free Compass API Key
- Wallet (EOA or smart account guide)
Introduction
This guide demonstrates how to combine two simple transactions:- Set allowance on Uniswap
- Swap on Uniswap
Setup
The full, uninterrupted code is available at the end of the tutorial.
Get Authorization
Before you can bundle transactions, you need to get an authorization from the Compass API and sign it with your private key. This ensures only you can execute the batch.Bundle the Actions
Now let’s bundle the allowance and swap actions for atomic execution. This step shows how to combine both actions into a single transaction using the Compass API.Create Bundled Transaction
Bundle the allowance and swap actions for atomic execution. This step shows how to combine both actions into a single transaction using the Compass API.Any transactional endpoint in Compass API can be turned into an action, see API Reference.
Execute the Transaction
The final step is to sign and broadcast the transaction to the network. This will execute your bundled actions in a single atomic transaction.Full Code
Here is the full script from the tutorial. Copy and paste into your code editor and play around!Resources
Compass API Docs
Access detailed API documentation and references
GitHub Examples
View more code examples and implementations