Using Compass API with Safe Smart Accounts
This guide demonstrates how to integrate Compass API SDK with Safe Starter Kit SDK to create and use smart accounts for DeFi operations.Prerequisites
Implementation Guide
Import dependencies and load environment
First, import the necessary dependencies and load your environment variables.
Create Safe client and initialize Compass API SDK
You have two options for setting up your Safe client:
- Option A:Use an existing Safe by providing its address.
- Option B:Deploy a new Safe by providing the signer’s address (uncomment the relevant code in the script).
Create and prepare batched operations
Here’s an example of increasing allowance and supplying tokens to Aave. If you
are deploying a new Safe, only include the
ALLOWANCE_INCREASE operation in
the first transaction. The Safe will not have any tokens initially, so the
AAVE_SUPPLY operation should be executed in a subsequent transaction after
funding the Safe with USDC.Full Code
Here is the full script from the tutorial. Copy and paste in your code editor and play around!Common Operation Examples
Here are some examples of different DeFi operations you can perform:Token Swaps
Lending Operations
Token Approvals
Resources
Compass API Docs
Access detailed API documentation and references
Safe Starter Kit Documentation
Learn more about Safe’s smart account features
GitHub Examples
View more code examples and implementations