Cross-chain payments interceptor and router in a form of a browser extension


Prize Pool

Magnee is a browser extension that intercepts payable Ethereum transactions on any dapp and lets users pay from a different chain or token. When a dapp calls eth_sendTransaction with a non-zero value, Magnee catches it, shows the user their token balances across supported chains (Ethereum, Optimism, Base, Arbitrum), fetches a bridge quote via Li.Fi, and executes the cross-chain payment.
The extension wraps window.ethereum (and EIP-6963 announced providers) to intercept transactions at the provider level — no dapp modifications needed. On the destination chain, an EIP-7702 delegate contract (MagneeDelegateAccount) receives the bridged funds and forwards the original call, preserving msg.sender as the user's EOA address. This means NFT mints, DeFi interactions, and contract whitelists all work as if the user transacted directly.
Cross-chain execution uses EIP-712 signed authorizations: the user signs the intended action before bridging, and the delegate contract verifies this signature on the destination chain when the Li.Fi executor delivers the funds. Same-chain batching uses wallet_sendCalls (ERC-5792) to combine token approval + bridge call in a single transaction.
User preferences (slippage tolerance, preferred tokens per chain, gas limit multiplier) are stored in ENS text records under com.magnee.settings, making them portable across browsers and devices, with chrome.storage.sync as a local fallback.
The project also includes a transaction explorer web app that traces Magnee transactions end-to-end across chains using the Li.Fi status API, and a MetaMask patch tool that bypasses five EIP-7702 guards (three bugs, two intentional blocks) in MetaMask's current release.
Really hope the dev experience in building on EIP-7702 would become less sloppy soon! :)
Monorepo structure — Bun workspaces with six packages: Solidity contracts (Foundry), the browser extension (Vite + React + TypeScript), a shared UI library (@magnee/ui with Radix primitives), a landing/explorer web app, a test dapp, and a MetaMask patch tool.
Provider interception — The extension injects a content script at document_start that wraps window.ethereum.request(). It also intercepts EIP-6963 announceProvider events and installs a property trap via Object.defineProperty to catch late provider assignments. Only eth_sendTransaction with value > 0 is intercepted; everything else passes through untouched. A processing lock suppresses dapp-initiated wallet_switchEthereumChain calls while Magnee is mid-bridge to prevent chain state conflicts.
Li.Fi integration — I use @lifi/sdk's getContractCallsQuote to get a bridge quote that includes a destination contract call. The SDK is configured with a custom viem transport that isolates chain state — eth_chainId returns Magnee's tracked chain, not the dapp's, which solved persistent "chain wars" with dapps like Aave that aggressively switch chains back. Token discovery and balance fetching also use Li.Fi's endpoints (getTokens, getTokenBalancesByChain), cached client-side.
EIP-7702 + EIP-712 — The MagneeDelegateAccount contract (Solidity 0.8.33) is deployed once per chain. For cross-chain execution, the user signs an EIP-712 typed data message authorizing a specific call (target, value, data, nonce, deadline). Li.Fi's bridge executor calls executeWithSignature() on the destination chain, the contract verifies the signature via ecrecover, confirming signer == address(this) (the EOA in EIP-7702 context). Same-chain uses wallet_sendCalls (ERC-5792).
ENS settings — User preferences are stored as a JSON text record (com.magnee.settings) on ENS via the public resolver's setText. Loading priority: ENS → chrome.storage.sync → defaults. Settings are minified to fit the 255-char practical limit.
Hacky bits — MetaMask currently blocks all EIP-7702 transactions with five guards. Three are bugs ("0x04" !== "0x4" string comparison), two are intentional blocks. I wrote a shell script that downloads the official MetaMask release, auto-detects which minified JS bundle contains each guard, and patches them out with perl regex. It's been tested across three MetaMask versions. Also, the wallet bridge relays RPC calls from the extension popup through the service worker using chrome.scripting.executeScript to call window.ethereum in the original dapp tab — since the popup runs in a separate context with no direct DOM access.

