DeFi wallet testing is painful because the important state is split between the web app, the wallet extension, the chain, and the user’s signature intent. A normal browser script can click through the page and still miss the wallet prompt that matters. A browser agent has to cross that boundary and keep evidence from both sides.
Tangle Browser Agent is built for these flows: connect wallet, switch network, sign typed data, preview a transaction, submit, and verify the app state after confirmation.
What To Test
| Flow | Evidence to save |
|---|---|
| connect wallet | app state, wallet popup, selected account |
| switch network | requested chain, wallet confirmation, app network state |
| sign message | message text, signature prompt, app response |
| typed data signing | structured payload shown to the user |
| swap or supply | token, amount, route, gas, confirmation state |
| failure path | rejected signature, insufficient balance, wrong network |
Wallet integrations often use the provider pattern described by EIP-1193. Typed signing commonly uses EIP-712. Test evidence should show what the user was asked to approve, not only the app’s post-click state.
Agent Run Pattern
pnpm wallet:setup
pnpm wallet:onboard
pnpm wallet:anvil
pnpm wallet:validate
Then run a browser goal:
bad run \
--url https://app.example.com \
--goal "Connect MetaMask, switch to the local test network, submit a small swap, and verify the app shows the completed transaction"
For MetaMask-specific cases, read MetaMask Automated Testing For Wallet Flows.
Why Screenshots Matter More Here
Transaction safety is visual and contextual. The wallet prompt is where the user sees the account, chain, token, amount, and permission request. If the test cannot capture that moment, it can miss the real product risk.
| Risk | Browser evidence catches |
|---|---|
| wrong chain | wallet network prompt and app network indicator |
| wrong asset | token symbol and contract display |
| bad approval | approval amount and spender context |
| hidden rejection | wallet rejection screen and app error state |
| stale balance | balance before and after the transaction |
The public MetaMask developer docs are a useful baseline for wallet connection behavior. Your test artifacts should show how your app actually presents that behavior.
Wallet State Matrix
Test more than the happy path.
| State | Expected behavior |
|---|---|
| no wallet installed | app explains supported wallets |
| wallet locked | app waits or prompts user to unlock |
| wrong network | app requests switch or blocks action |
| empty balance | app blocks submit before gas failure |
| rejected signature | app recovers without corrupting state |
| pending transaction | app shows truthful status |
| failed transaction | app exposes failure and retry path |
The state matrix should be small enough to run but broad enough to catch user-trust issues. Wallet bugs are often not contract bugs; they are mismatches between app state and what the wallet asked the user to approve.
Evidence Hand-Off
Every DeFi wallet test should hand off a packet to engineering:
| Evidence | Why it matters |
|---|---|
| app screenshot before prompt | shows context |
| wallet prompt screenshot | shows approval details |
| provider event log | connects app state to wallet response |
| final app screenshot | verifies user-visible result |
| transaction hash or local trace | connects UI to chain or simulator |
For a MetaMask-focused breakdown, read MetaMask Automated Testing For Wallet Flows. For general browser evidence, read AI Browser Testing With Evidence Traces.
What This Does Not Prove
DeFi wallet testing in a browser does not prove smart contract safety. It proves the user flow, wallet prompts, and UI state around the transaction. Pair it with contract tests, simulation, audits, and monitoring.
Decision Rule
Use a browser agent when the wallet flow has extension popups, signatures, or network changes. Require screenshots of the wallet prompt and the final app state before accepting the run.
FAQ
What is DeFi wallet testing?
It is testing the browser and wallet flow for actions such as connect, sign, approve, swap, supply, and withdraw.
Why is wallet testing harder than normal browser testing?
The key state lives outside the page in a wallet extension or provider, so the test must handle popups and signature prompts.
Does this replace smart contract audits?
No. It tests the user flow around contract interactions, not the contract logic itself.
What does Tangle Browser Agent add?
It can drive browser and wallet flows while saving screenshots, actions, and verdicts for review.