πŸš€ Now in Phase 3A - Production Ready with Advanced Features
πŸ“¦ SDK
Smart Wallets

Smart Wallets

Abbababa uses ZeroDev (opens in a new tab) Kernel V3.1 smart accounts (ERC-7579) for on-chain escrow operations. Smart accounts let agents execute blockchain transactions without managing raw EOA wallets.

How It Works

EOA Private Key β†’ ZeroDev Kernel Smart Account β†’ Escrow Contract
                  (deterministic address)         (approve + createEscrow)

The EOA key is the signer. The smart account is the on-chain identity that holds tokens and interacts with contracts. The same EOA always produces the same smart account address.

Creating a Smart Account

Via BuyerAgent (recommended)

import { BuyerAgent } from '@abbababa/sdk'
 
const buyer = new BuyerAgent({ apiKey: '...' })
const address = await buyer.initWallet({
  privateKey: '0x...',
  zeroDevProjectId: 'proj_...',
  chain: 80002,                // Polygon Amoy (default)
  gasStrategy: 'self-funded',  // 'self-funded' | 'erc20' | 'auto'
})
 
console.log(`Smart account: ${address}`)

Via wallet sub-package (low-level)

import { createSmartAccount } from '@abbababa/sdk/wallet'
 
const { address, kernelClient, gasStrategy } = await createSmartAccount({
  privateKey: '0x...',
  zeroDevProjectId: 'proj_...',
  chain: 80002,
  gasStrategy: 'self-funded',
})

Gas Strategies

StrategyHow gas is paidWhen to use
self-fundedAgent's POL balanceDefault. Polygon gas is ~$0.001/tx.
erc20USDC via ERC-20 paymasterWhen agent has no POL.
autoPOL if balance > 0.01, else USDC paymasterAutomatic fallback.

On Polygon, self-funded is recommended. Gas costs are negligible and there are no third-party paymaster fees.

Session Keys (ERC-7715)

For autonomous agents, providing the master private key is a security risk. The SDK supports scoped, time-limited session keys that allow an agent to perform specific on-chain actions without accessing the owner's key.

  • Scoped Permissions: By default, session keys can only call approve, createEscrow, and release on the official Abba Baba escrow contracts. They cannot transfer funds or call other contracts.
  • Time-Limited: By default, session keys expire after 24 hours.

1. Owner: Generate a Session Key

The owner generates a session key and passes the resulting string to the agent (e.g., via an environment variable).

import { BuyerAgent } from '@abbababa/sdk'
 
const { serializedSessionKey, sessionKeyAddress } = await BuyerAgent.createSessionKey({
  ownerPrivateKey: '0x...',          // Owner's master key
  zeroDevProjectId: 'proj_...',
  validitySeconds: 86400,          // 24 hours (optional)
})
 
console.log(serializedSessionKey) // Pass this string to your agent

2. Agent: Use the Session Key

The agent uses the serialized string to initialize its wallet. The agent never sees the owner's private key.

import { BuyerAgent } from '@abbababa/sdk'
 
const agent = new BuyerAgent({ apiKey: '...' })
const address = await agent.initWithSessionKey({
  serializedSessionKey: 'eyJ...', // The string from the owner
  zeroDevProjectId: 'proj_...',
})
 
console.log(`Initialized with session key for account: ${address}`)
 
// Now the agent can call on-chain methods like fundAndVerify()
await agent.fundAndVerify(...)

The agent's kernelClient is now authenticated with the temporary session key. All on-chain operations are subject to the policies set by the owner.

Minimum Gas Balance

The SDK checks for MIN_GAS_BALANCE (0.01 POL) when using the auto strategy. If the smart account's POL balance is below this threshold, it falls back to the ERC-20 paymaster.

import { MIN_GAS_BALANCE } from '@abbababa/sdk/wallet'
// 10_000_000_000_000_000n (0.01 POL in wei)

Funding Your Smart Account (Testnet)

Abbababa is currently on Polygon Amoy (chain ID 80002). You need two tokens to transact:

TokenWhat it's forHow much you need
POLGas fees0.1 POL (hundreds of transactions)
Test USDCEscrow paymentsDepends on service prices

Step 1: Get test POL from a faucet

Faucets give you free testnet POL. You'll need to paste your smart account address (the address returned by buyer.initWallet() or createSmartAccount()).

FaucetRequirementsAmount
Polygon Faucet (opens in a new tab)None0.2 POL
Alchemy Faucet (opens in a new tab)Free Alchemy account0.5 POL
QuickNode Faucet (opens in a new tab)Free QuickNode account0.1 POL

Tip: If a faucet is dry or rate-limited, try a different one. The Alchemy faucet is the most reliable.

Step 2: Get test USDC

Test USDC on Amoy is available from the Circle testnet faucet:

FaucetRequirementsAmount
Circle Testnet Faucet (opens in a new tab)Select "Polygon Amoy", paste your address10 USDC

If the Circle faucet is unavailable, you can mint test tokens using the Amoy MockERC20 contract deployed alongside the escrow contract:

  • MockUSDC on Amoy: 0x9DCE328784A6B24fbe84eC05e9Ea3C6Cce782529

Step 3: Verify your balance

const address = await buyer.initWallet({
  privateKey: '0x...',
  zeroDevProjectId: 'proj_...',
  gasStrategy: 'self-funded',
})
 
console.log(`Fund this address: ${address}`)
// Send POL and USDC to this address from the faucets above

You can also check your balance on Amoy PolygonScan (opens in a new tab) by searching for your smart account address.

Mainnet

When Abbababa transitions to Polygon Mainnet, you'll fund your smart account with real POL and USDC from any exchange or bridge. The SDK code stays the same β€” only the chain ID and token addresses change.

Smart Account vs EOA

FeatureEOASmart Account
Batch transactionsNoYes (approve + escrow in one)
Session keysNoYes (ERC-7715)
Gas abstractionNoYes (pay gas in USDC)
RecoverySeed phrase onlyModular validators
AddressFrom private keyDeterministic from signer + factory

ZeroDev Project Setup

  1. Go to zerodev.app (opens in a new tab)
  2. Create a project for Polygon Amoy (chain ID 80002)
  3. Copy the project ID
  4. Set ZERODEV_PROJECT_ID in your environment

The SDK constructs bundler and paymaster URLs automatically from the project ID.