Skip to content

Commit 09eb1d7

Browse files
committed
feat: scripts and address for main net deploy
still needs front-end config
1 parent 5f73ede commit 09eb1d7

File tree

3 files changed

+442
-0
lines changed

3 files changed

+442
-0
lines changed
Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
name: "Deploy Dawn Mainnet Contracts"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
fund_amount:
7+
description: "Amount of ETH to fund the paymaster (e.g., 0.1)"
8+
required: false
9+
default: "0"
10+
deploy_bundler:
11+
description: "Deploy bundler service"
12+
type: boolean
13+
required: false
14+
default: false
15+
deploy_auth_server:
16+
description: "Deploy auth server"
17+
type: boolean
18+
required: false
19+
default: false
20+
21+
env:
22+
HUSKY: 0
23+
CI: true
24+
25+
jobs:
26+
deploy-contracts:
27+
runs-on: ubuntu-latest
28+
outputs:
29+
contracts: ${{ steps.deploy.outputs.contracts }}
30+
steps:
31+
- uses: actions/checkout@v4
32+
with:
33+
submodules: recursive
34+
35+
- name: Setup pnpm
36+
uses: pnpm/action-setup@v4
37+
with:
38+
version: 9.11.0
39+
40+
- name: Use Node.js
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: lts/Iron
44+
cache: "pnpm"
45+
46+
- name: Install dependencies
47+
run: pnpm install -r --frozen-lockfile
48+
49+
- name: Install contract dependencies
50+
run: pnpm install -r --frozen-lockfile
51+
working-directory: packages/contracts
52+
53+
- name: Build contracts
54+
run: pnpm build
55+
working-directory: packages/contracts
56+
57+
- name: Deploy contracts to Dawn Mainnet
58+
id: deploy
59+
env:
60+
WALLET_PRIVATE_KEY: ${{ secrets.DAWN_MAINNET_DEPLOYER_PRIVATE_KEY }}
61+
KEY_REGISTRY_OWNER_PRIVATE_KEY: ${{ secrets.DAWN_MAINNET_KEY_REGISTRY_OWNER_PRIVATE_KEY }}
62+
run: |
63+
# Deploy all contracts
64+
pnpm hardhat deploy \
65+
--network dawnMainnet \
66+
--file ../auth-server/stores/dawn-mainnet.json \
67+
--fund ${{ github.event.inputs.fund_amount }} \
68+
--keyregistryowner $KEY_REGISTRY_OWNER_PRIVATE_KEY
69+
70+
# Read the deployed contracts
71+
echo "contracts=$(cat ../auth-server/stores/dawn-mainnet.json)" >> $GITHUB_OUTPUT
72+
working-directory: packages/contracts
73+
74+
- name: Initialize OIDC Key Registry with Google keys
75+
env:
76+
WALLET_PRIVATE_KEY: ${{ secrets.DAWN_MAINNET_KEY_REGISTRY_OWNER_PRIVATE_KEY }}
77+
run: |
78+
pnpm hardhat run scripts/add-google-keys.ts --network dawnMainnet
79+
working-directory: packages/contracts
80+
81+
- name: Verify deployment
82+
env:
83+
WALLET_PRIVATE_KEY: ${{ secrets.DAWN_MAINNET_DEPLOYER_PRIVATE_KEY }}
84+
run: |
85+
node verify-dawn-deployment.js
86+
working-directory: packages/contracts
87+
88+
- name: Upload deployment artifacts
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: dawn-mainnet-deployment
92+
path: packages/auth-server/stores/dawn-mainnet.json
93+
retention-days: 90
94+
95+
- name: Comment deployment info on commit
96+
uses: actions/github-script@v7
97+
with:
98+
script: |
99+
const contracts = JSON.parse('${{ steps.deploy.outputs.contracts }}');
100+
const comment = `
101+
## 🚀 Dawn Mainnet Deployment Complete
102+
103+
**Network:** Dawn Mainnet (Chain ID: 30715)
104+
**RPC URL:** https://zksync-os-mainnet-dawn.zksync.io
105+
**Block Explorer:** https://zksync-os-mainnet-dawn.staging-scan-v2.zksync.dev
106+
107+
### Deployed Contracts
108+
109+
| Contract | Address |
110+
|----------|---------|
111+
| Factory | \`${contracts.accountFactory}\` |
112+
| WebAuthn Validator | \`${contracts.passkey}\` |
113+
| Session Validator | \`${contracts.session}\` |
114+
| Beacon | \`${contracts.beacon}\` |
115+
| Guardian Recovery | \`${contracts.recovery}\` |
116+
| OIDC Recovery | \`${contracts.recoveryOidc}\` |
117+
| OIDC Key Registry | \`${contracts.oidcKeyRegistry}\` |
118+
| Paymaster | \`${contracts.accountPaymaster}\` |
119+
120+
### Next Steps
121+
1. Add these addresses to \`packages/auth-server/stores/client.ts\`
122+
2. Update bundler configuration if deploying bundler service
123+
3. Deploy auth-server if needed
124+
4. Test account creation and transactions
125+
`;
126+
127+
github.rest.repos.createCommitComment({
128+
owner: context.repo.owner,
129+
repo: context.repo.repo,
130+
commit_sha: context.sha,
131+
body: comment
132+
});
133+
134+
deploy-bundler:
135+
needs: deploy-contracts
136+
if: ${{ github.event.inputs.deploy_bundler == 'true' }}
137+
runs-on: ubuntu-latest
138+
steps:
139+
- uses: actions/checkout@v4
140+
141+
- name: Deploy Bundler Service
142+
run: |
143+
echo "Bundler deployment would happen here"
144+
# TODO: Add bundler deployment steps when ready
145+
146+
deploy-auth-server:
147+
needs: deploy-contracts
148+
if: ${{ github.event.inputs.deploy_auth_server == 'true' }}
149+
runs-on: ubuntu-latest
150+
steps:
151+
- uses: actions/checkout@v4
152+
153+
- name: Setup pnpm
154+
uses: pnpm/action-setup@v4
155+
with:
156+
version: 9.11.0
157+
158+
- name: Use Node.js
159+
uses: actions/setup-node@v4
160+
with:
161+
node-version: lts/Iron
162+
cache: "pnpm"
163+
164+
- name: Download deployment artifacts
165+
uses: actions/download-artifact@v4
166+
with:
167+
name: dawn-mainnet-deployment
168+
path: packages/auth-server/stores/
169+
170+
- name: Install dependencies
171+
run: pnpm install -r --frozen-lockfile
172+
173+
- name: Build auth server
174+
run: pnpm nx build auth-server
175+
env:
176+
NUXT_PUBLIC_CHAIN_ID: 30715
177+
178+
- name: Deploy to Firebase (or other hosting)
179+
run: |
180+
echo "Auth server deployment would happen here"
181+
# TODO: Configure Firebase or other hosting for Dawn Mainnet
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
#!/bin/bash
2+
3+
# Dawn Mainnet Pre-Deployment Checklist
4+
# Run this before deploying to ensure everything is ready
5+
6+
set -e
7+
8+
echo "🔍 Dawn Mainnet Pre-Deployment Checklist"
9+
echo "========================================="
10+
echo ""
11+
12+
ISSUES=0
13+
14+
# Check 1: Environment variables
15+
echo "1. Checking environment variables..."
16+
if [ -z "$WALLET_PRIVATE_KEY" ]; then
17+
echo " ❌ WALLET_PRIVATE_KEY not set"
18+
ISSUES=$((ISSUES + 1))
19+
else
20+
echo " ✅ WALLET_PRIVATE_KEY set"
21+
fi
22+
23+
if [ -z "$KEY_REGISTRY_OWNER_PRIVATE_KEY" ]; then
24+
echo " ❌ KEY_REGISTRY_OWNER_PRIVATE_KEY not set"
25+
ISSUES=$((ISSUES + 1))
26+
else
27+
echo " ✅ KEY_REGISTRY_OWNER_PRIVATE_KEY set"
28+
fi
29+
echo ""
30+
31+
# Check 2: Cast CLI installed
32+
echo "2. Checking for cast CLI..."
33+
if command -v cast &> /dev/null; then
34+
echo " ✅ cast installed ($(cast --version | head -n1))"
35+
else
36+
echo " ❌ cast not installed"
37+
echo " Install with: curl -L https://foundry.paradigm.xyz | bash && foundryup"
38+
ISSUES=$((ISSUES + 1))
39+
fi
40+
echo ""
41+
42+
# Check 3: pnpm installed
43+
echo "3. Checking for pnpm..."
44+
if command -v pnpm &> /dev/null; then
45+
echo " ✅ pnpm installed ($(pnpm --version))"
46+
else
47+
echo " ❌ pnpm not installed"
48+
echo " Install with: npm install -g pnpm"
49+
ISSUES=$((ISSUES + 1))
50+
fi
51+
echo ""
52+
53+
# Check 4: Network connectivity
54+
echo "4. Checking Dawn Mainnet connectivity..."
55+
if curl -s -X POST -H "Content-Type: application/json" \
56+
--data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' \
57+
https://zksync-os-mainnet-dawn.zksync.io | grep -q "result"; then
58+
echo " ✅ Dawn Mainnet RPC accessible"
59+
else
60+
echo " ❌ Cannot connect to Dawn Mainnet RPC"
61+
ISSUES=$((ISSUES + 1))
62+
fi
63+
echo ""
64+
65+
# Check 5: Deployer balance
66+
if [ ! -z "$WALLET_PRIVATE_KEY" ]; then
67+
echo "5. Checking deployer wallet balance..."
68+
DEPLOYER_ADDRESS=$(cast wallet address --private-key $WALLET_PRIVATE_KEY 2>/dev/null || echo "")
69+
70+
if [ ! -z "$DEPLOYER_ADDRESS" ]; then
71+
echo " 📍 Deployer address: $DEPLOYER_ADDRESS"
72+
73+
BALANCE=$(cast balance $DEPLOYER_ADDRESS --rpc-url https://zksync-os-mainnet-dawn.zksync.io 2>/dev/null || echo "0")
74+
BALANCE_ETH=$(cast --to-unit $BALANCE ether 2>/dev/null || echo "0")
75+
76+
echo " 💰 Balance: $BALANCE_ETH ETH"
77+
78+
# Check if balance is sufficient (at least 0.5 ETH recommended)
79+
BALANCE_GWEI=$(cast --to-unit $BALANCE gwei 2>/dev/null | cut -d. -f1)
80+
if [ "$BALANCE_GWEI" -lt 500000000 ]; then
81+
echo " ⚠️ Low balance. Recommended: at least 1 ETH"
82+
echo " Transfer ETH to: $DEPLOYER_ADDRESS"
83+
ISSUES=$((ISSUES + 1))
84+
else
85+
echo " ✅ Sufficient balance for deployment"
86+
fi
87+
else
88+
echo " ❌ Invalid WALLET_PRIVATE_KEY"
89+
ISSUES=$((ISSUES + 1))
90+
fi
91+
else
92+
echo "5. Skipping balance check (WALLET_PRIVATE_KEY not set)"
93+
fi
94+
echo ""
95+
96+
# Check 6: Key registry owner balance
97+
if [ ! -z "$KEY_REGISTRY_OWNER_PRIVATE_KEY" ]; then
98+
echo "6. Checking key registry owner wallet balance..."
99+
OWNER_ADDRESS=$(cast wallet address --private-key $KEY_REGISTRY_OWNER_PRIVATE_KEY 2>/dev/null || echo "")
100+
101+
if [ ! -z "$OWNER_ADDRESS" ]; then
102+
echo " 📍 Owner address: $OWNER_ADDRESS"
103+
104+
BALANCE=$(cast balance $OWNER_ADDRESS --rpc-url https://zksync-os-mainnet-dawn.zksync.io 2>/dev/null || echo "0")
105+
BALANCE_ETH=$(cast --to-unit $BALANCE ether 2>/dev/null || echo "0")
106+
107+
echo " 💰 Balance: $BALANCE_ETH ETH"
108+
109+
# Check if balance is sufficient (at least 0.01 ETH recommended)
110+
BALANCE_GWEI=$(cast --to-unit $BALANCE gwei 2>/dev/null | cut -d. -f1)
111+
if [ "$BALANCE_GWEI" -lt 10000000 ]; then
112+
echo " ⚠️ Low balance. Recommended: at least 0.1 ETH"
113+
echo " Transfer ETH to: $OWNER_ADDRESS"
114+
ISSUES=$((ISSUES + 1))
115+
else
116+
echo " ✅ Sufficient balance"
117+
fi
118+
else
119+
echo " ❌ Invalid KEY_REGISTRY_OWNER_PRIVATE_KEY"
120+
ISSUES=$((ISSUES + 1))
121+
fi
122+
else
123+
echo "6. Skipping owner balance check (KEY_REGISTRY_OWNER_PRIVATE_KEY not set)"
124+
fi
125+
echo ""
126+
127+
# Check 7: Contracts build
128+
echo "7. Checking if contracts are built..."
129+
if [ -d "packages/contracts/artifacts-zk" ]; then
130+
echo " ✅ Contracts appear to be built"
131+
else
132+
echo " ⚠️ Contracts not built yet"
133+
echo " Run: cd packages/contracts && pnpm build"
134+
fi
135+
echo ""
136+
137+
# Check 8: Dependencies installed
138+
echo "8. Checking if dependencies are installed..."
139+
if [ -d "node_modules" ] && [ -d "packages/contracts/node_modules" ]; then
140+
echo " ✅ Dependencies installed"
141+
else
142+
echo " ⚠️ Dependencies not fully installed"
143+
echo " Run: pnpm install -r"
144+
fi
145+
echo ""
146+
147+
# Summary
148+
echo "========================================="
149+
if [ $ISSUES -eq 0 ]; then
150+
echo "✅ All checks passed! Ready for deployment."
151+
echo ""
152+
echo "To deploy, run:"
153+
echo " ./scripts/deploy-dawn-mainnet.sh"
154+
exit 0
155+
else
156+
echo "❌ Found $ISSUES issue(s). Please fix them before deploying."
157+
echo ""
158+
echo "Need help? See: docs/DAWN_MAINNET_DEPLOYMENT.md"
159+
exit 1
160+
fi

0 commit comments

Comments
 (0)