Skip to main content
This example walks an EOA holder through depositing into a Pods yield strategy via an ERC-4337 smart account (a Gnosis Safe with the Safe 4337 module). Instead of signing each on-chain transaction with the EOA, you create a smart account owned by the EOA, fund it once, then deposit by signing a single userOperation that the bundler executes — with gas sponsored by a paymaster.

Overview

This example covers:
  • Creating a smart account for an EOA with POST /smart-account
  • Waiting for the smart account to deploy on-chain
  • Funding the smart account from the EOA (a standard ERC-20 transfer)
  • Generating a deposit userOperation with GET /strategies/:id/bytecode?output=userOperation
  • Signing the userOperation (Safe 4337 SafeOp EIP-712)
  • Propagating it with POST /aa/send-user-operation
The signer key is the smart account’s owner. The EOA you use to sign the userOperation must be the same owner you pass to POST /smart-account, or the Safe 4337 module rejects the signature (AA24).

Prerequisites

  • Node.js 18+
  • Pods API key
  • An EOA (private key) with USDC on Polygon to deposit
  • Basic understanding of async/await
Gas is sponsored. The deposit userOperation is paid by a paymaster, so the smart account only needs the asset you are depositing (USDC) — it does not need native MATIC for gas.

Installation

Environment Variables

Create a .env file:
Never commit your .env file to version control. Add it to .gitignore.

Step-by-Step Walkthrough

1. Initialize clients

2. Create the smart account

Create a smart account owned by the EOA. The address is deterministic for an owner + chainId, so this call is idempotent — repeated calls return the same record.
Response:
The endpoint returns 200 with the record immediately, while the Safe is deployed in the background. The next step waits for that deployment to land on-chain.

3. Wait for on-chain deployment

The smart account must have code on-chain before you can build a userOperation for it. Poll until it’s deployed.
Skip this and Step 5 fails: building a userOperation for a not-yet-deployed smart account throws Could not create a new SmartAccount without an owner.

4. Fund the smart account

Move the asset you want to deposit from the EOA to the smart account. This is a plain ERC-20 transfer() — there is no Pods endpoint for it.
Only the deposit asset (USDC) is required — gas for the deposit userOperation is sponsored by a paymaster.

5. Request the deposit userOperation

Ask the API for the lend bytecode as a fully-populated (but unsigned) userOperation, using the smart account as the wallet. Gas limits and paymasterAndData are filled in for you.
The userOperation contains sender, nonce, initCode, callData, the gas fields, paymasterAndData, and an empty signature you fill in next.

6. Sign the userOperation (SafeOp)

A Safe with the 4337 module validates the userOperation against the module’s SafeOp EIP-712 hash — not the vanilla ERC-4337 UserOperation hash. The EIP-712 verifyingContract is the Safe 4337 module, and the packed signature is 12 zero bytes (validAfter + validUntil) followed by the 65-byte ECDSA signature.

7. Send the userOperation

Propagate the signed userOperation to the bundler. The endpoint returns the userOpHash.
Numeric userOperation fields may be decimal or 0x-hex strings — the endpoint normalizes them, and the SafeOp signature hashes the integer values, so signing the fields exactly as returned by Step 5 is correct.

8. Track the deposit (optional)

Use the id from Step 5 to poll the action until it reaches a terminal state.

Error Handling

Expected Output

Next Steps

Strategy Deposit (EOA)

The same deposit flow signing directly with an EOA

Check Positions

Track the smart account’s positions

Strategy Withdrawal

Withdraw from strategies, including cross-chain

API Reference

View complete API documentation