Testing the Wallet Extension
This final section covers loading your wallet extension in Chrome and testing it with the Pod Racing dApp from the webapp tutorial.
Building the Extension
From the webapp-tutorial directory:
# Install dependencies if needed
yarn install
# Build the extension
node esbuild.extension.mjs
You should see:
Extension build complete!
The build creates:
test-extension/dist/background.jstest-extension/dist/content-script.jstest-extension/dist/offscreen.jstest-extension/dist/popup.js
Loading in Chrome
- Open Chrome and navigate to
chrome://extensions/ - Enable Developer mode (toggle in top-right corner)
- Click Load unpacked
- Select the
test-extensionfolder (notdist/) - The extension "Aztec Tutorial Wallet" should appear
You should see:
- Extension icon in the toolbar
- "Service Worker" link under "Inspect views"
First Launch
Click the extension icon to open the popup:
- You'll see the setup screen prompting you to create a master password
- Enter and confirm your password, then click "Create Wallet"
- Once the password is set, you'll be prompted to create your first account
- Enter an account alias (optional) and click "Create Account"
The account appears with status "Pending" (not deployed yet).
Deploying an Account
To deploy the account contract:
- The wallet should already be unlocked from the setup step above
- Click "Deploy" next to the account
- Wait for the transaction (uses SponsoredFPC, no tokens needed)
- Status changes to "Deployed"
Check the console (Service Worker inspector) for logs:
[offscreen] Initializing wallet...
[offscreen] Wallet initialized
[offscreen] Received message: deploy-account
Running the dApp
In another terminal, start the webapp tutorial:
cd docs/examples/webapp-tutorial
# Start the dev server
yarn dev
Open http://localhost:5173 in Chrome.
Connecting the Wallet
- In the dApp, select network "Browser Wallet"
- Click "Connect Wallet"
- Choose "Browser Wallet"
The extension should:
- Show a badge with "1" (pending connection)
- When you click the icon, show the connection request
To approve:
- Click the extension icon
- Go to "Approvals" tab
- Review the origin (localhost:5173)
- Click "Connect"
The dApp should now show your account address.
Deploying a Contract
In the dApp:
- Click "Deploy Pod Racing Contract"
- The extension shows a pending transaction
To approve:
- Click the extension icon
- Go to "Approvals" tab
- Review the transaction:
- From: your account address
- Method: sendTx
- Calls: contract deployment
- Click "Approve"
Wait for the transaction to complete. This takes 30-60 seconds due to:
- Proof generation (WASM)
- Block confirmation
Playing the Game
Once deployed:
- Click "Boost" in the dApp
- Approve the transaction in the extension
- Watch your pod accelerate!
Each boost is a private transaction that:
- Updates your pod's speed (private state)
- Generates a ZK proof
- Gets included in a block
Debugging
Background Script
- Go to
chrome://extensions/ - Find "Aztec Tutorial Wallet"
- Click "Service Worker" under "Inspect views"
- Check Console for
[background]logs
Offscreen Document
- On the extensions page, look for "Offscreen document"
- Click to open DevTools
- Check Console for
[offscreen]logs
Content Script
- Open DevTools on the dApp page (F12)
- Check Console for
[content-script]logs - May need to filter by extension
Common Issues
"Cannot read properties of undefined"
- PXE (Private eXecution Environment) hasn't initialized yet
- Check offscreen console for initialization errors
"Account not found"
- Account isn't loaded in memory
- Try entering password to unlock
"Transaction rejected"
- Check if the Aztec node is reachable
- Verify SponsoredFPC is registered
Popup doesn't show pending items
- Refresh the popup (close and reopen)
- Check background console for errors
Verifying on Explorer
If your network has a block explorer, you can verify transactions:
- Copy your transaction hash from logs
- Visit the explorer
- Search for the transaction
- Verify it's included in a block
Reloading After Changes
When you modify the extension:
- Rebuild:
node esbuild.extension.mjs - Go to
chrome://extensions/ - Click the refresh icon on the extension
- Reload any open dApp pages
End-to-End Test Flow
Complete test checklist:
- Build extension
- Load in Chrome
- Create account in popup
- Deploy account (SponsoredFPC)
- Start dApp
- Connect wallet (approve in popup)
- Verify account shows in dApp
- Deploy Pod Racing contract (approve in popup)
- Play game (approve boost transactions)
- Check transactions in explorer
Production Considerations
Before releasing a wallet extension:
- Security audit - Professional review of crypto code
- Key management - Consider hardware wallet support
- Network switching - Support testnet, mainnet
- Error recovery - Graceful handling of failures
- Backup/restore - Seed phrase support
- Multi-account - Better account management UI
- Transaction history - Show past transactions
- Note management - Display synced notes
Summary
You've built a functional wallet extension that:
- Creates and stores encrypted accounts
- Deploys contracts using SponsoredFPC
- Connects to dApps via the wallet SDK protocol
- Approves transactions with a popup UI
- Generates ZK proofs for private transactions
This is the foundation for a production Aztec wallet. The architecture patterns - offscreen documents, message routing, BaseWallet extension - apply to any browser wallet.
What's Next?
- Add more account types (ECDSA, multisig)
- Implement transaction history
- Add network switching
- Build a note browser
- Support hardware wallets
Happy building!