Add pre-signing transaction simulation, EIP-712 permit analysis, and approval risk checks to your wallet or dApp so users see what they sign in advance.
You visit a “token claim” site. The transaction looks normal—just a contract interaction. You approve it without a second thought. 48 hours later, your entire wallet is drained through a permit signature you didn’t understand. Transaction simulation would have caught it. This guide shows you how to build that last line of defense.
Why Transaction Simulation Matters
Last Line of Defense
Users trust your app to protect them—make that trust count
Permit Protection
Catch EIP-712 signatures that can drain wallets without transactions
Approval Awareness
Show users their existing exposure before they add more
Why developers choose Webacy:
Pre-signing simulation — Show users exactly what will happen before they approve
EIP-712 signature analysis — Decode and risk-score permit/signature requests
Basic familiarity with REST APIs or the Webacy SDK
Your application’s transaction signing flow identified for integration
Pre-Signing Protection
The moment before a user signs a transaction is your last chance to protect them.
Transaction Simulation
Simulate every transaction before it gets signed. The endpoint is POST /scan/{fromAddress}/transactions, where fromAddress is the signer, and it takes the serialized unsigned transaction (raw), not the to/data/value fields. Every EVM library produces it as a 0x hex string: ethers Transaction.from({...}).unsignedSerialized, viem serializeTransaction(...), web3.js bytesToHex(tx.serialize()) (its serialize() returns bytes). A 66-character tx hash is also accepted for a transaction that is already mined.
import { ThreatClient } from '@webacy-xyz/sdk';import { Transaction } from 'ethers';const client = new ThreatClient({ apiKey: process.env.WEBACY_API_KEY });// The transaction your dApp is about to ask the user to signconst raw = Transaction.from({ type: 2, chainId: 1, to: '0xContractAddress...', data: '0xTransactionData...', value: 0n, nonce: 12, gasLimit: 100_000n, maxFeePerGas: 30_000_000_000n, maxPriorityFeePerGas: 1_000_000_000n,}).unsignedSerialized;const result = await client.scan.scanTransaction('0xUserAddress...', { tx: { from: '0xUserAddress...', raw }, chain: 1, // Ethereum mainnet domain: 'connected-dapp.com',});// One item per simulated asset movement (or approval): party = the signer,// counterparty = who receives / can spend, asset = the token contract.const { simulation } = result as unknown as TransactionScanResponse;for (const item of simulation) { const { txData, counterpartyRisk, assetRisk } = item; console.log(`${txData.changeType} ${txData.rawAmount ?? ''} ${txData.symbol ?? txData.assetType} → ${txData.counterpartyAddress}`); if ((counterpartyRisk.high ?? 0) > 0 || (assetRisk.high ?? 0) > 0) { console.warn('⛔ High risk: ', counterpartyRisk.issues?.flatMap((i) => i.tags.map((t) => t.name))); } if (counterpartyRisk.overallRisk === undefined) { // The recipient could not be scored (provider outage or budget) — treat as unknown, not safe console.warn('⚠️ Recipient risk unavailable, ask the user to double-check the address'); }}interface TransactionScanResponse { simulation: Array<{ partyRisk: AddressRisk; counterpartyRisk: AddressRisk; /** `address` is `null` for the native asset (ETH) */ assetRisk: AddressRisk & { address: string | null }; txData: { changeType: 'TRANSFER' | 'APPROVE'; assetType?: 'NATIVE' | 'ERC20' | 'ERC721' | 'ERC1155'; rawAmount?: string; symbol?: string; partyAddress: string; counterpartyAddress: string; assetAddress: string | null; }; /** Attached to the first item only, when the calldata calls a known-risky function */ functionRisk?: { selector: string; functionName: string; riskLevel: string; description: string }; }>; block?: number | null; // absent / null for a pending (unsigned) transaction chain: string; descriptor: string; // signed TLV descriptor (hardware-wallet integrations) timestamp: string;}// When a party could not be scored (provider outage or time budget) only `address` is present —// never read a missing score as "clean".interface AddressRisk { address: string; overallRisk?: number; // 0–100 high?: number; // count of high-severity findings medium?: number; issues?: Array<{ tags: Array<{ key: string; name: string; description: string; severity: number }> }>;}
import requestsresponse = requests.post( "https://api.webacy.com/scan/0xUserAddress.../transactions", headers={ "x-api-key": "YOUR_API_KEY", "Content-Type": "application/json" }, json={ "tx": { "from": "0xUserAddress...", "raw": "0x02f00180843b9aca008506fc23ac00830186a094d8da6bf26964af9d7eed9e03e53415d37aa96045872386f26fc1000080c0" }, "chain": 1, "domain": "app.example.com" })result = response.json()for item in result["simulation"]: tx = item["txData"] print(tx["changeType"], tx.get("rawAmount"), tx.get("symbol") or tx.get("assetType"), "->", tx["counterpartyAddress"]) if item["counterpartyRisk"].get("high", 0) > 0: print("HIGH RISK counterparty:", [t["name"] for i in item["counterpartyRisk"].get("issues", []) for t in i["tags"]])
What to show users:
Field
What It Means
Display Priority
simulation[].txData
Each asset movement (TRANSFER) or approval (APPROVE) the transaction would cause: amount, token, recipient / spender
Always show
simulation[].counterpartyRisk
Risk profile of the recipient or spender (overallRisk 0–100, high / medium counts, tagged issues)
Show with color coding — high > 0 means block or strong warning
simulation[].assetRisk
Risk profile of the token contract involved
Show when high > 0
simulation[0].functionRisk
Present on the first item when the calldata calls a known-risky function (e.g. setApprovalForAll)
Show prominently if present
block
Absent (or null) for a pending transaction, the block number for a mined one
Informational
The chain can be passed either as the numeric chain in the body (1, 56, 137, 10, 42161, 8453) or as the ?chain= query (eth, bsc, pol, opt, arb, base); the query wins when both are present. tx.from must match the fromAddress in the path.
An empty simulation array is inconclusive, not safe. It means the simulation produced no asset movement and the calldata named no recipient or spender to score — a call that reverts, a contract call with no transfer, or a degraded simulation read. Treat it as unknown and ask the user to verify the address, never as a green light. A party whose overallRisk / high / medium are missing (only address present) could not be scored in time — same rule.
Permit signatures are one of the most dangerous attack vectors. A single signature can authorize unlimited token spending without any on-chain transaction.
The Silent Drain: Unlike regular transactions, permit signatures don’t show up on block explorers until the attacker uses them. A user can sign a permit and see nothing happen—until days later when everything is gone.
The spender / recipient is a known drainer, hacker or sanctioned address
simulation.domainRisk.riskLevel = high
The dApp domain you passed is a known phishing site
simulation.functionRisk present
The typed data embeds calldata for a risky function (Safe execTransaction, delegatecall, ownership transfer, …)
Only Ethereum mainnet is supported for EIP-712 scans: data.domain.chainId must be 1 (or pass ?chain=eth). msg.from must match the fromAddress in the path. Pass the dApp origin as domain to get simulation.domainRisk.
Approval Risk Management
Users often have approvals they’ve forgotten about. Help them understand their exposure.
Current Approval Scanning
Show users their existing approvals before they add more.
curl -X GET "https://api.webacy.com/wallets/0xUserAddress.../approvals?chain=eth" \ -H "x-api-key: YOUR_API_KEY"