Skip to content

Commit 3f395fe

Browse files
authored
feat: enhance deployment artifacts with ABI, bytecode, and metadata (#3618)
1 parent 815b04d commit 3f395fe

File tree

10 files changed

+876
-114
lines changed

10 files changed

+876
-114
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Remote deployment configuration example
2+
# Copy this file to .env and fill in your values
3+
4+
# Required for remote deployments
5+
RPC_URL=https://eth-sepolia.g.alchemy.com/v2/YOUR_API_KEY
6+
PRIVATE_KEY=0xYOUR_PRIVATE_KEY
7+
8+
# Optional: For contract verification
9+
ETHERSCAN_API_KEY=YOUR_ETHERSCAN_API_KEY
10+
11+
# Optional: Environment configuration
12+
# Valid values: local, staging, production
13+
# If not set, deployment artifacts will use flat structure for backward compatibility
14+
DEPLOYMENT_ENV=staging
15+
16+
# Optional: Paymaster configuration
17+
# Initial deposit amount in wei (default: 1 ether)
18+
PAYMASTER_INITIAL_DEPOSIT=1000000000000000000
19+
20+
# Optional: Initial bundler address (default: deployer address)
21+
INITIAL_BUNDLER=0xYOUR_BUNDLER_ADDRESS

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,6 @@ docs/
1515
.env
1616
.env.*
1717
broadcast/
18-
deployments/local.json
18+
19+
# Deployment artifacts
20+
deployments/local/

tee-worker/omni-executor/aa-contracts/DEPLOYMENT.md

Lines changed: 102 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ This guide provides comprehensive instructions for deploying Account Abstraction
55
## 📋 Overview
66

77
The deployment script deploys three core contracts:
8-
- **EntryPoint**: The main entry point for ERC-4337 user operations
9-
- **OmniAccountFactory**: Factory contract for creating OmniAccount smart wallets
8+
- **EntryPointV1**: The main entry point for ERC-4337 user operations
9+
- **OmniAccountFactoryV1**: Factory contract for creating OmniAccount smart wallets
1010
- **SimplePaymaster**: Paymaster contract for sponsoring transactions
1111

1212
## 🔧 Prerequisites
@@ -30,13 +30,17 @@ The script automatically detects and configures for these networks:
3030

3131
| Network | Chain ID | Filename |
3232
|---------|----------|----------|
33-
| Ethereum Mainnet | 1 | `mainnet.json` |
34-
| Ethereum Sepolia | 11155111 | `sepolia.json` |
33+
| Ethereum Mainnet | 1 | `ethereum.json` |
34+
| Ethereum Sepolia | 11155111 | `ethereum-sepolia.json` |
35+
| Arbitrum Mainnet | 42161 | `arbitrum.json` |
36+
| Arbitrum Sepolia | 421614 | `arbitrum-sepolia.json` |
3537
| BSC Mainnet | 56 | `bsc.json` |
3638
| BSC Testnet | 97 | `bsc-testnet.json` |
3739
| Polygon Mainnet | 137 | `polygon.json` |
38-
| Polygon Mumbai | 80001 | `mumbai.json` |
39-
| Local Anvil | 1337 | `local.json` |
40+
| Polygon Mumbai | 80001 | `polygon-mumbai.json` |
41+
| HyperEVM Mainnet | 999 | `hyperevm.json` |
42+
| HyperEVM Testnet | 998 | `hyperevm-testnet.json` |
43+
| Local Anvil | 1337/31337 | `local.json` |
4044

4145
## ⚙️ Configuration
4246

@@ -54,6 +58,7 @@ PAYMASTER_INITIAL_DEPOSIT=1000000000000000000 # 1 ETH in wei (default: 1 ETH)
5458
INITIALIZE_PAYMASTER=true # Whether to initialize paymaster (default: true)
5559
INITIAL_BUNDLER=0x1234567890abcdef... # Initial bundler address (default: deployer)
5660
SAVE_DEPLOYMENT_FILE=true # Save deployment file (default: false, set true for official deployments)
61+
DEPLOYMENT_ENV=staging # Environment subdirectory (e.g., staging, production)
5762
ETHERSCAN_API_KEY=ABC123 # For contract verification
5863
```
5964

@@ -73,6 +78,24 @@ forge script script/Deploy.s.sol:Deploy \
7378
-vvv
7479
```
7580

81+
### Using Remote Deployment Script (Recommended)
82+
83+
The `deploy-remote.sh` script handles deployment and automatic ABI enrichment:
84+
85+
```bash
86+
# Set environment variables in .env
87+
DEPLOYMENT_ENV=staging # Optional: staging, production, etc.
88+
89+
# Run the deployment script
90+
./deploy-remote.sh
91+
```
92+
93+
This script will:
94+
1. Deploy all contracts to the specified network
95+
2. Save enhanced artifacts with addresses and bytecode
96+
3. Automatically enrich artifacts with ABIs from Foundry build outputs
97+
4. Save to `deployments/[environment]/[network].json`
98+
7699

77100
### Ethereum Mainnet with Verification
78101
```bash
@@ -98,11 +121,11 @@ Chain ID: 97
98121
Deployer address: 0x...
99122
Deployer balance: 1.5 ETH
100123
101-
🚀 Deploying EntryPoint...
102-
EntryPoint deployed at: 0x...
124+
🚀 Deploying EntryPointV1...
125+
EntryPointV1 deployed at: 0x...
103126
104-
🚀 Deploying OmniAccountFactory...
105-
OmniAccountFactory deployed at: 0x...
127+
🚀 Deploying OmniAccountFactoryV1...
128+
OmniAccountFactoryV1 deployed at: 0x...
106129
107130
🚀 Deploying SimplePaymaster...
108131
✅ SimplePaymaster deployed at: 0x...
@@ -112,33 +135,73 @@ Deployer balance: 1.5 ETH
112135
113136
=== DEPLOYMENT COMPLETE ===
114137
📋 Contract Addresses:
115-
EntryPoint: 0x...
116-
OmniAccountFactory: 0x...
117-
SimplePaymaster: 0x...
138+
EntryPointV1: 0x...
139+
OmniAccountFactoryV1: 0x...
140+
SimplePaymaster: 0x...
118141
```
119142

120-
### JSON File
121-
Location: `deployments/bsc-testnet.json`
143+
### JSON File (Enhanced Artifacts)
144+
Location: `deployments/[environment]/[network].json` (e.g., `deployments/staging/bsc-testnet.json`)
145+
122146
```json
123147
{
124148
"network": "BSC Testnet",
125149
"chainId": 97,
126150
"timestamp": 1703001234,
151+
"blockNumber": 123456,
127152
"deployer": "0x...",
128153
"contracts": {
129-
"EntryPoint": "0x...",
130-
"OmniAccountFactory": "0x...",
131-
"SimplePaymaster": "0x..."
154+
"EntryPointV1": {
155+
"address": "0x...",
156+
"abi": [...], // Full contract ABI
157+
"bytecode": "0x608060...", // Deployed bytecode
158+
"metadata": {}
159+
},
160+
"OmniAccountFactoryV1": {
161+
"address": "0x...",
162+
"abi": [...],
163+
"bytecode": "0x608060...",
164+
"metadata": {}
165+
},
166+
"SimplePaymaster": {
167+
"address": "0x...",
168+
"abi": [...],
169+
"bytecode": "0x608060...",
170+
"metadata": {
171+
"initialBundler": "0x..."
172+
}
173+
}
132174
}
133175
}
134176
```
135177

178+
The artifacts are saved in environment-based subdirectories:
179+
- **Local**: `deployments/local/`
180+
- **Staging**: `deployments/staging/`
181+
- **Production**: `deployments/production/`
182+
- **No environment**: `deployments/` (backward compatible)
183+
136184
### Broadcast Files
137185
Foundry creates detailed transaction logs in:
138186
```
139187
broadcast/Deploy.s.sol/[CHAIN_ID]/run-latest.json
140188
```
141189

190+
## 📝 ABI Enrichment
191+
192+
The deployment scripts automatically enrich artifacts with contract ABIs after deployment. If this fails or you need to manually enrich:
193+
194+
```bash
195+
# Run the ABI enrichment script
196+
node extract-abis.js
197+
```
198+
199+
This script:
200+
- Reads all deployment files from `deployments/`
201+
- Extracts ABIs from Foundry build artifacts
202+
- Updates deployment files with full contract ABIs
203+
- Handles both old (address-only) and new (enhanced) formats
204+
142205
## 🔍 Contract Verification
143206

144207
### Automatic Verification
@@ -157,20 +220,20 @@ forge script script/Deploy.s.sol:Deploy \
157220
If automatic verification fails:
158221

159222
```bash
160-
# Verify EntryPoint
223+
# Verify EntryPointV1
161224
forge verify-contract \
162225
--chain-id [CHAIN_ID] \
163226
--constructor-args $(cast abi-encode "constructor()") \
164227
[ENTRYPOINT_ADDRESS] \
165-
src/core/EntryPoint.sol:EntryPoint \
228+
src/core/EntryPointV1.sol:EntryPointV1 \
166229
--etherscan-api-key $ETHERSCAN_API_KEY
167230

168231
# Verify Factory
169232
forge verify-contract \
170233
--chain-id [CHAIN_ID] \
171234
--constructor-args $(cast abi-encode "constructor(address)" [ENTRYPOINT_ADDRESS]) \
172235
[FACTORY_ADDRESS] \
173-
src/accounts/OmniAccountFactory.sol:OmniAccountFactory \
236+
src/accounts/OmniAccountFactoryV1.sol:OmniAccountFactoryV1 \
174237
--etherscan-api-key $ETHERSCAN_API_KEY
175238

176239
# Verify Paymaster
@@ -186,18 +249,32 @@ forge verify-contract \
186249

187250
### Deployment Files Management
188251

189-
The script can optionally create deployment files in `deployments/` folder when `SAVE_DEPLOYMENT_FILE=true`. For official deployments:
252+
The script creates enhanced deployment files when `SAVE_DEPLOYMENT_FILE=true`. For official deployments:
190253

191254
```bash
192255
# After successful deployment, commit only official deployment files
193-
git add deployments/mainnet.json # For Ethereum mainnet
194-
git add deployments/bsc.json # For BSC mainnet
195-
git add deployments/bsc-testnet.json # For BSC testnet (if official)
256+
git add deployments/production/ethereum.json # For Ethereum mainnet
257+
git add deployments/production/arbitrum.json # For Arbitrum mainnet
258+
git add deployments/staging/bsc-testnet.json # For BSC testnet staging
196259
git commit -m "Deploy AA contracts to mainnet"
197260

198261
# Tag official releases
199262
git tag v1.0.0-mainnet
200263
git push origin v1.0.0-mainnet
201264
```
202265

266+
### Using Deployment Artifacts
267+
268+
```javascript
269+
// Load deployment artifacts in your application
270+
const deployment = require('./deployments/staging/arbitrum-sepolia.json');
271+
272+
// Access contract addresses and ABIs
273+
const entryPointAddress = deployment.contracts.EntryPointV1.address;
274+
const entryPointABI = deployment.contracts.EntryPointV1.abi;
275+
276+
// Create contract instance (ethers.js example)
277+
const entryPoint = new ethers.Contract(entryPointAddress, entryPointABI, provider);
278+
```
279+
203280
**Note**: The `broadcast/` folder is in `.gitignore` and should not be committed as it contains transaction details that change with each deployment run.

tee-worker/omni-executor/aa-contracts/README.md

Lines changed: 97 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Contains Solidity code for ERC-4337 Account Abstraction.
55
This project includes code from https://github.com/eth-infinitism/account-abstraction git commit sha: cc3893bcaf2272c163ce89d5eb9eadb8e6b52db7
66
licensed under the GNU General Public License v3.0.
77

8-
## Compiling
8+
## Compiling
99

1010
`forge compile`
1111

@@ -29,4 +29,99 @@ This script will:
2929

3030
The script keeps Anvil running after deployment. Press Ctrl+C to stop both the script and Anvil.
3131

32-
Also see [DEPLOYMENT.md](./DEPLOYMENT.md) for more information.
32+
## Deployment Artifacts
33+
34+
When deploying contracts, the scripts now generate enhanced deployment artifacts in the `deployments/` directory. These artifacts include:
35+
36+
- **Contract Address**: The deployed address of each contract
37+
- **ABI**: The full Application Binary Interface for contract interaction
38+
- **Bytecode**: The deployed bytecode for verification purposes
39+
- **Metadata**: Optional additional information (e.g., configuration parameters)
40+
41+
### Artifact Structure
42+
43+
Deployment artifacts are saved in environment-based subdirectories with network-specific JSON files:
44+
- Local development: `deployments/local/local.json`
45+
- Staging: `deployments/staging/ethereum-sepolia.json`, `deployments/staging/arbitrum-sepolia.json`, etc.
46+
- Production: `deployments/production/ethereum.json`, `deployments/production/arbitrum.json`, etc.
47+
48+
```json
49+
{
50+
"network": "Local Network",
51+
"chainId": 31337,
52+
"timestamp": 1234567890,
53+
"blockNumber": 1,
54+
"deployer": "0x...",
55+
"contracts": {
56+
"EntryPoint": {
57+
"address": "0x...",
58+
"abi": [...],
59+
"bytecode": "0x...",
60+
"metadata": {}
61+
},
62+
// ... other contracts
63+
}
64+
}
65+
```
66+
67+
### Enabling Artifact Generation
68+
69+
To enable deployment artifact generation, set the `SAVE_DEPLOYMENT_FILE` environment variable:
70+
71+
```bash
72+
SAVE_DEPLOYMENT_FILE=true forge script script/Deploy.s.sol --rpc-url <RPC_URL> --broadcast
73+
```
74+
75+
The local deployment script (`./local-deploy.sh`) automatically enables artifact generation.
76+
77+
### Using Deployment Artifacts
78+
79+
Once generated, deployment artifacts can be used to interact with deployed contracts:
80+
81+
```javascript
82+
const deployment = require('./deployments/local/local.json');
83+
84+
// Get contract address and ABI
85+
const entryPointAddress = deployment.contracts.EntryPoint.address;
86+
const entryPointABI = deployment.contracts.EntryPoint.abi;
87+
88+
// Create contract instance (ethers.js example)
89+
const entryPoint = new ethers.Contract(entryPointAddress, entryPointABI, provider);
90+
```
91+
92+
### Remote Deployment
93+
94+
For remote deployments, use the provided script template:
95+
96+
```bash
97+
# Set the environment variables
98+
# Then run:
99+
./deploy-remote.sh
100+
```
101+
102+
The script will:
103+
1. Deploy contracts to the specified network
104+
2. Generate deployment artifacts with addresses and bytecode
105+
3. Enrich artifacts with ABIs from Foundry build outputs
106+
4. Save the complete artifacts to `deployments/<environment>/<network>.json`
107+
108+
### Artifact Contents
109+
110+
Each deployment artifact includes:
111+
112+
- **network**: Network name (e.g., "Ethereum Sepolia", "Local Network")
113+
- **chainId**: Chain ID of the deployment network
114+
- **timestamp**: Unix timestamp of deployment
115+
- **blockNumber**: Block number at deployment time
116+
- **deployer**: Address that deployed the contracts
117+
- **contracts**: Object containing each deployed contract with:
118+
- **address**: Deployed contract address
119+
- **abi**: Full contract ABI for interaction
120+
- **bytecode**: Deployed bytecode for verification
121+
- **metadata**: Optional configuration parameters (e.g., paymaster type, initial bundler)
122+
123+
### Verification
124+
125+
The included bytecode can be used to verify deployed contracts on block explorers or to ensure the deployed code matches the source.
126+
127+
Also see [DEPLOYMENT.md](./DEPLOYMENT.md) for more information.

tee-worker/omni-executor/aa-contracts/deploy-local.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ deploy_contracts() {
5555
export PRIVATE_KEY="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80" # Anvil's first private key
5656
export OMNI_EXECUTOR_SIGNER=$OMNI_EXECUTOR_SIGNER
5757
export PAYMASTER_TYPE=$PAYMASTER_TYPE
58+
export SAVE_DEPLOYMENT_FILE=true # Enable saving enhanced deployment artifacts
59+
export DEPLOYMENT_ENV=local # Use local environment subdirectory
5860

5961
# Show which paymaster is being deployed
6062
if [ "$PAYMASTER_TYPE" = "demo" ]; then
@@ -153,6 +155,13 @@ forge compile
153155
# Deploy contracts
154156
deploy_contracts
155157

158+
# Enrich deployment artifacts with ABIs if Node.js is available
159+
if command -v node &> /dev/null && [ -f "$SCRIPT_DIR/extract-abis.js" ]; then
160+
echo ""
161+
echo "📝 Enriching deployment artifacts with ABIs..."
162+
node "$SCRIPT_DIR/extract-abis.js" || echo "⚠️ Failed to enrich ABIs, but deployment was successful"
163+
fi
164+
156165
# Keep Anvil running if we started it
157166
if [ "$ANVIL_RUNNING" = false ]; then
158167
echo ""

0 commit comments

Comments
 (0)