Overview
This demo uses Dynamic server wallets and sponsored transactions to create and manage many customer wallets, then sweep their balances into a central omnibus account:- Programmatically create wallets (including the omnibus) with 2-of-2 threshold signatures for strong control
- Use a 7702 smart account and Pimlico paymaster to sponsor gas on Base Sepolia (no ETH needed)
- Mint random demo USDC amounts (up to 1000) to each customer wallet, then transfer all balances to the omnibus account
Prerequisites
- Node.js 18+
- Dynamic API token and Environment ID
- Pimlico API key (for gasless on Base Sepolia)
- Cloned example repository: github.com/dynamic-labs/examples/nodejs-omnibus-sweep
- Embedded wallets enabled in your Dynamic dashboard
- “Allow multiple embedded wallets per chain” toggled on in Embedded Wallets settings
Find your API tokens and Environment ID in the Dynamic Dashboard.
Setup
Copy the.example.env
file to .env
and fill in your credentials:
.env
How It Works
Phases
- Wallet creation (customers + one omnibus)
- Funding customers with USDC (gasless mint)
- Sweeping all customer balances to the omnibus account
Demo Configuration
- Default wallets: 5 (override with a numeric CLI argument)
- Funding amount: random whole-dollar USDC per wallet from 1 to 1000
- USDC decimals: 6; sweeping converts dollars to token units before transfer
- Confirmations: waits for 2 transaction confirmations
- Concurrency: wallet creation is sequential; transactions run up to 10 in parallel
- Chain: Base Sepolia (chainId 84532)
- Token: demo USDC address from
constants.ts
Components
- Wallet creation: Uses Dynamic’s server wallet client to create EVM wallets with 2-of-2 threshold signatures (TSS). (src/libs/dynamic.ts)
- LocalAccount adapter: Bridges Dynamic signing methods into a
viem
LocalAccount
so it can be used with a smart account client. (src/libs/viem.ts) - Smart Account + Paymaster: Builds a 7702-style smart account and submits sponsored transactions via Pimlico (EntryPoint v0.7). (src/libs/pimlico.ts)
- Orchestration: Coordinates create → fund → sweep → report. (src/omnibus-sweep.ts)
- Explorer + utilities: Formatting, explorers, unit conversion. (src/utils.ts)
- Configuration: Env reads, token ABI, contract addresses. (constants.ts)
Configuration and Environment
- The
.env
variables defined in Setup are read byconstants.ts
and used across the libs. When a per-chain override is not set, the default Pimlico URL is derived fromPIMLICO_API_KEY
.
Security Model
- Wallets are created with
ThresholdSignatureScheme.TWO_OF_TWO
andbackUpToClientShareService: false
. - Transactions are signed via Dynamic’s server-side signing methods and executed through a smart account.
- For fresh addresses with no code deployed, the script signs an authorization targeting the configured account implementation and includes it with the first transaction.
- Entry point: v0.7; smart account is created via
permissionless
7702 helpers.
Run the Demo
Default run (creates 5 wallets):Sample Output
Here’s what you’ll see when running the demo with 10 wallets:Troubleshooting
- 401/403 during wallet creation: Check
DYNAMIC_API_TOKEN
andDYNAMIC_ENVIRONMENT_ID
. - Multiple wallets per chain not allowed: Check “Allow multiple embedded wallets per chain” in Embedded Wallets settings.
- Paymaster/bundler errors: Verify
PIMLICO_API_KEY
or setPIMLICO_BUNDLER_URL_84532
. - Insufficient confirmations: The script waits for 2 confirmations per transaction; on congested testnets, this may take time.