What They are
Product Accounts are isolated on-chain accounts for each DeFi product (Earn, Borrow, Trade, etc.). When a user first uses Earn, we create an Earn Product Account. If they later use Borrow, they get a separate Borrow Product Account. Both accounts are controlled by the user’s main wallet. Compass never holds custody of the funds. Compass just orchestrates creation and transaction routing.Why Use Them
- Transaction Bundling: Bundle any workflow, such as approvals, swap, and deposit in a single transaction. Save gas and improve UX.
- Gas Sponsorship: All transactions within Product Accounts can be gas-sponsored. Users never need ETH, you can sponsor their gas across deposits, withdrawals, swaps, and borrows.
- No Fund Intermingling: Your Earn positions can’t get liquidated because of your Leverage positions. Each product operates in isolation.
- Clean Accounting: Separate on-chain addresses per product simplify compliance and auditing.
- Independent Development: Add new products without refactoring existing integrations.
How They Work
Product Accounts are controlled by your user’s wallet. Compass orchestrates account creation and transaction routing. Users sign all transactions. Compass never holds keys or custody. This happens all through API calls.Create your first Earn account
Create an Earn Account on Base. The API returns an unsigned transaction that you must sign and broadcast separately.NoteCreating an Earn Account is usually the first step before users can interact with DeFi venues. If you want to sponsor gas, you can request EIP-712 typed data from the API and have a relayer submit it; here we keep it simple so the owner covers their own gas.
- This example uses no gas sponsorship - the owner pays for their own transaction
- Full source code is available in our public GitHub repository: CompassLabs/api_usecases – create_earn_account
Prerequisites
1
Install Dependencies
Install the required packages.
2
Set Environment Variables
Create a
.env file:Implementation
1
Import Libraries & Environment Variables
2
Initialize SDK
3
Get Unsigned Transaction
Request an unsigned transaction to create an Earn Account. The
owner and sender are the same address (no gas sponsorship).4
Sign and Broadcast Transaction
Sign the transaction with your private key and broadcast it to the Base network.