Smart Accounts with ZeroDev
Learn how to use Compass API SDK with ZeroDev for smart account operations
Using Compass API with ZeroDev Smart Accounts
This guide demonstrates how to integrate Compass API SDK with ZeroDev to create and use smart accounts for DeFi operations. The combination enables:
- Account abstraction features
- Gas fee abstraction (pay in any token)
- Simplified DeFi operations
- Enhanced security through smart account features
Prerequisites
Install Dependencies
Install the required packages:
Set Environment Variables
Create a .env
file in your project root:
Implementation Guide
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.
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: