Blog

DeFi Wallet Testing With Browser Agents

DeFi wallet testing needs browser automation for extensions, network prompts, signatures, transaction previews, screenshots, and run evidence.

Drew Stone
browser-agentdefiwallet-testing
Browser agent testing a DeFi wallet flow with extension popup and transaction evidence

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

FlowEvidence to save
connect walletapp state, wallet popup, selected account
switch networkrequested chain, wallet confirmation, app network state
sign messagemessage text, signature prompt, app response
typed data signingstructured payload shown to the user
swap or supplytoken, amount, route, gas, confirmation state
failure pathrejected 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.

RiskBrowser evidence catches
wrong chainwallet network prompt and app network indicator
wrong assettoken symbol and contract display
bad approvalapproval amount and spender context
hidden rejectionwallet rejection screen and app error state
stale balancebalance 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.

StateExpected behavior
no wallet installedapp explains supported wallets
wallet lockedapp waits or prompts user to unlock
wrong networkapp requests switch or blocks action
empty balanceapp blocks submit before gas failure
rejected signatureapp recovers without corrupting state
pending transactionapp shows truthful status
failed transactionapp 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:

EvidenceWhy it matters
app screenshot before promptshows context
wallet prompt screenshotshows approval details
provider event logconnects app state to wallet response
final app screenshotverifies user-visible result
transaction hash or local traceconnects 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.