Skip to content

Commit 810e272

Browse files
authored
Add demo app to showcase the non custody AA flow (#3551)
1 parent 228b10a commit 810e272

37 files changed

+19999
-40
lines changed

tee-worker/omni-executor/aa-contracts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ out/
66
!/broadcast
77
/broadcast/*/31337/
88
/broadcast/**/dry-run/
9+
broadcast/
910

1011
# Docs
1112
docs/
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.*
7+
.yarn/*
8+
!.yarn/patches
9+
!.yarn/plugins
10+
!.yarn/releases
11+
!.yarn/versions
12+
13+
# testing
14+
/coverage
15+
16+
# next.js
17+
/.next/
18+
/out/
19+
20+
# production
21+
/build
22+
23+
# misc
24+
.DS_Store
25+
*.pem
26+
27+
# debug
28+
npm-debug.log*
29+
yarn-debug.log*
30+
yarn-error.log*
31+
.pnpm-debug.log*
32+
33+
# env files (can opt-in for committing if needed)
34+
.env*
35+
36+
# vercel
37+
.vercel
38+
39+
# typescript
40+
*.tsbuildinfo
41+
next-env.d.ts
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# AA Demo App - Account Abstraction Demo Application
2+
3+
A Next.js application demonstrating Account Abstraction (ERC-4337) functionality with OmniAccount smart contracts. This demo showcases how to create and manage smart contract wallets with root key authorization for non-custodial operations.
4+
5+
## Overview
6+
7+
This application demonstrates:
8+
- **Account Abstraction (AA)**: Create smart contract wallets (OmniAccounts) that can be controlled by multiple signers
9+
- **Root Key Authorization**: Add authorized signers to control the smart account
10+
- **Non-Custodial Flow**: Users maintain full control of their accounts while enabling delegated operations
11+
- **ERC-4337 Integration**: Implements the ERC-4337 standard for account abstraction
12+
13+
## Prerequisites
14+
15+
- Node.js 18+ and npm
16+
- [Foundry](https://book.getfoundry.sh/getting-started/installation) installed
17+
- A web3 wallet (MetaMask or similar)
18+
- Git
19+
20+
## Quick Start
21+
22+
Follow these steps to run the demo application locally:
23+
24+
### 1. Deploy Smart Contracts
25+
26+
First, navigate to the parent directory and deploy the contracts:
27+
28+
```bash
29+
# From the aa-contracts directory (parent of aa-demo-app)
30+
cd /path/to/aa-contracts
31+
32+
# Start Anvil (local Ethereum node) and deploy contracts
33+
./local-deploy.sh
34+
35+
# Keep this terminal open - Anvil needs to keep running
36+
```
37+
38+
You should see output like:
39+
```
40+
🎉 All contracts deployed successfully!
41+
42+
Contract Addresses:
43+
===================
44+
EntryPoint: 0x5fbdb2315678afecb367f032d93f642f64180aa3
45+
OmniAccountFactory: 0xe7f1725e7734ce288f8367e1bb143e90bb3f0512
46+
SimplePaymaster: 0x...
47+
```
48+
49+
### 2. Update Demo App Configuration
50+
51+
In a new terminal, update the demo app with the deployed contract addresses:
52+
53+
```bash
54+
# Still in the aa-contracts directory
55+
./update-demo-addresses.sh
56+
```
57+
58+
This creates/updates the `.env.local` file in the demo app with the correct contract addresses.
59+
60+
### 3. Run the Demo App
61+
62+
```bash
63+
# Navigate to the demo app directory
64+
cd aa-demo-app
65+
66+
# Install dependencies (first time only)
67+
npm install
68+
69+
# Start the development server
70+
npm run dev
71+
```
72+
73+
Open [http://localhost:3000](http://localhost:3000) in your browser.
74+
75+
### 4. Use the Application
76+
77+
1. **Connect Wallet**: Click "Connect Wallet" and select your wallet
78+
- Make sure you're connected to the Anvil network (Chain ID: 1337)
79+
- If not, add a custom network in MetaMask:
80+
- Network Name: Anvil Local
81+
- RPC URL: http://localhost:8545
82+
- Chain ID: 1337
83+
- Currency Symbol: ETH
84+
85+
2. **View Your OmniAccount**: After connecting, you'll see your pre-calculated OmniAccount address
86+
87+
3. **Fund Your Account**: Send some ETH to your OmniAccount address
88+
- Use MetaMask to send ETH to the displayed address
89+
- Or use Anvil's funded accounts
90+
91+
4. **Authorize Root Key**: Once funded, authorize your wallet as a root signer
92+
- This deploys your OmniAccount contract
93+
- Adds your wallet as an authorized signer
94+
95+
## Verifying On-Chain
96+
97+
To verify your OmniAccount was created and the root signer was added:
98+
99+
```bash
100+
# From the aa-contracts directory
101+
cd /path/to/aa-contracts
102+
103+
# Set your OmniAccount address (copy from the UI)
104+
ACCOUNT=0xYOUR_OMNI_ACCOUNT_ADDRESS
105+
106+
# Check if the contract exists
107+
cast code $ACCOUNT --rpc-url http://localhost:8545
108+
# Should return bytecode (not "0x")
109+
110+
# Check if your wallet is a root signer
111+
cast call $ACCOUNT "isRootSigner(address)(bool)" 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 --rpc-url http://localhost:8545
112+
# Should return "true"
113+
114+
# Check the owner
115+
cast call $ACCOUNT "owner()(bytes32)" --rpc-url http://localhost:8545
116+
117+
# Check the client ID
118+
cast call $ACCOUNT "clientId()(bytes)" --rpc-url http://localhost:8545
119+
```
120+
121+
## Project Structure
122+
123+
```
124+
aa-demo-app/
125+
├── src/
126+
│ ├── app/ # Next.js app router pages
127+
│ ├── components/ # React components
128+
│ │ ├── AAWalletInfo.tsx # Displays OmniAccount information
129+
│ │ ├── FundingGuide.tsx # Guide for funding the account
130+
│ │ ├── RootKeyAuthorization.tsx # Root key authorization flow
131+
│ │ └── WalletConnect.tsx # Wallet connection component
132+
│ ├── contracts/ # Contract ABIs
133+
│ └── lib/ # Utilities and configuration
134+
│ ├── aa-utils.ts # Account abstraction utilities
135+
│ ├── constants.ts # Contract addresses and ABIs
136+
│ └── wagmi.ts # Web3 configuration
137+
└── public/ # Static assets
138+
```
139+
140+
## Troubleshooting
141+
142+
### "AA Wallet Not Ready"
143+
- Ensure your wallet is connected
144+
- Check you're on the correct network (Chain ID: 1337)
145+
- Verify contracts are deployed (check Anvil terminal)
146+
147+
### Transaction Failures
148+
- Ensure your OmniAccount is funded with ETH
149+
- Check Anvil is still running
150+
- Verify you're using the correct network
151+
152+
### Anvil Errors
153+
You might see errors like `execution reverted` for `symbol()` or `decimals()` calls. These are harmless - they're from wallets trying to detect if addresses are ERC20 tokens.
154+
155+
## Environment Variables
156+
157+
The app uses these environment variables (set automatically by `update-demo-addresses.sh`):
158+
159+
- `NEXT_PUBLIC_CHAIN_ID`: Network chain ID (1337 for Anvil)
160+
- `NEXT_PUBLIC_ENTRYPOINT_ADDRESS`: EntryPoint contract address
161+
- `NEXT_PUBLIC_FACTORY_ADDRESS`: OmniAccountFactory contract address
162+
- `NEXT_PUBLIC_RPC_URL`: Ethereum RPC URL (http://localhost:8545)
163+
164+
## Development
165+
166+
To modify the app:
167+
168+
1. Smart contract changes: Update contracts in parent `src/` directory
169+
2. Re-deploy: Run `./local-deploy.sh` again
170+
3. Update addresses: Run `./update-demo-addresses.sh`
171+
4. The app hot-reloads automatically
172+
173+
## Learn More
174+
175+
- [ERC-4337 Specification](https://eips.ethereum.org/EIPS/eip-4337)
176+
- [Foundry Book](https://book.getfoundry.sh/)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { NextConfig } from "next";
2+
3+
const nextConfig: NextConfig = {
4+
/* config options here */
5+
};
6+
7+
export default nextConfig;

0 commit comments

Comments
 (0)