Learn how to use Compass API SDK with ZeroDev for smart account operations
This guide demonstrates how to integrate Compass API SDK with ZeroDev to create and use smart accounts for DeFi operations. The combination enables:
Install Dependencies
Install the required packages:
Set Environment Variables
Create a .env
file in your project root:
Import dependencies and initialize clients
First, import the necessary dependencies, load your environment variables, and initialize the public client and entry point.
Create signer, validator, kernel account, and paymaster
Set up the signer, ECDSA validator, kernel account, paymaster, and kernel client. This step prepares your smart account for batched DeFi operations.
Create and prepare batched operations
Use the Compass API SDK to create batched DeFi operations (e.g., allowance increase and Aave supply). Convert the result to the format expected by the kernel client.
Send batched operations and handle result
Send the batched user operation and wait for confirmation. The script will print the transaction hash and confirmation receipt, or an error if the operation fails.
Here is the full script from the tutorial. Copy and paste in your code editor and play around!
Here are some examples of different DeFi operations you can perform:
Access detailed API documentation and references
Learn more about ZeroDev’s smart account features
View more code examples and implementations