Hackathon MVP for disposable, task-scoped agent authority.
Give an AI agent a temporary capability, not a permanent wallet.
The project demonstrates two models: a disposable wallet per mission for maximum isolation, and a reusable wallet with multiple disposable permissions for repeated agent activity.
On top of that, agents can pay each other over x402 in USDC from a reusable wallet, with every payment screened live by the Intercepta API before the agent signs it and before the service accepts it. See Safe agent-to-agent payments; npm run demo runs it alongside the cards, and npm run demo -- --scenarios also plays the scripted payment scenarios.
Requirements: Node.js/npm, Foundry 1.6 or newer (anvil + forge; the demo chain runs the osaka hardfork for the
P-256 precompile) and network access (the demo forks Base Sepolia from https://sepolia.base.org, or
BASE_SEPOLIA_RPC_URL). For live screening put INTERCEPTA_API_KEY in .env (free key:
https://intercepta.io/ethglobal). Without it the demo still starts, but screening fails closed: every x402 payment is
refused and merchants show as unverified.
git clone https://github.com/DavideSilva/EphemeralWallet.git
cd EphemeralWallet
npm install
npm run demonpm run demo:
- forks Base Sepolia into Anvil on
127.0.0.1:8545(chain id 84532, real USDC) - installs
forge-stdif needed - deploys
MissionFactory,ReusableWalletFactoryand three demo merchants (teamLab Borderless, JR ticket office, Kawaguchiko ryokan); the fourth, Mount Fuji Weather, is the x402 weather service - creates fresh owner/agent/facilitator/payee keys, funds them, and creates the two x402 demo wallets
- starts the x402 service (port 4021), the Mount Fuji weather service (port 4022, a second x402 seller) and the agent daemon (port 4100)
- starts the UI at
http://localhost:5173(cards) andhttp://localhost:5173/payments(x402)
The UI signs as Anvil account #0 (no wallet popups) and issues cards to Anvil account #1 by default. Stop everything with Ctrl-C.
A card lets one agent spend at one merchant, up to a budget, until it expires.
- One-time card: its own
EphemeralMissionWallet, funded with the budget. One purchase, then it's used up; cancelling it refunds the balance. - Multi-use card: a permission on your
ReusablePermissionWalletaccount, which is opened the first time you issue one. The agent can buy until the budget or uses run out; cancelling revokes only that card.
When you issue a card, the app screens its merchant with Intercepta before anything happens on-chain. Pick one of the demo merchants or Another merchant to paste any address; Review and issue opens a confirmation with the check result:
- Verified: no scam, sanctions or stolen-funds history. Issue as normal.
- Caution or Unverified (risk signals, no record, or Intercepta unavailable): you tick "I understand the risk" to issue.
- Blocked: the card can't be issued.
The check runs in the Vite dev server (/api/screen/<address>) through @eaw/risk, so the key stays out of the browser. It needs INTERCEPTA_API_KEY in .env; without it every merchant shows as Unverified. It's an app-level check: the contract still only enforces the merchant, budget, uses and expiry. To see a Blocked result, use Intercepta's scam-flagged test address 0x39308ae43e5dda98db5fb17d005c5c764e5a2fed.
Each card's page shows the command to run in a second terminal:
npm run agent -- <card> "buy two teamLab Borderless adult tickets"<card> is the wallet address for a one-time card, or <wallet>-<id> for a multi-use card. The agent reads the merchant's on-chain catalog, plans the order, and sends it with the task as the on-chain memo.
Planning uses Claude (claude-opus-5) when Anthropic credentials are available, for example ANTHROPIC_API_KEY in a root .env (see .env.example). Otherwise, or with AGENT_PLANNER=offline, it matches the task against the catalog by keyword.
The agent isn't told its limits and sends over-limit orders anyway, so the card is the one that says no. Rejected attempts are mined as reverts and show up in the app's activity as Blocked, with the reason.
The fourth demo merchant, Mount Fuji Weather (tagged x402 · USDC), isn't a shop contract: it's the weather service, which sells a report for 0.01 USDC over x402. Its card is a multi-use card whose permission is in USDC (asset = USDC) and whose merchant is the service's payee, so the contract's approvePayment only ever pays that address, within the budget, uses and expiry. Issuing it moves the budget from your wallet into your account (npm run demo gives the UI's owner 10 USDC on the fork). The approval plugin isn't available on USDC cards.
npm run agent -- <card> "buy a mount fuji weather report"The agent reads the price from the service's 402 response, plans, and then, before every payment, screens the payee, the token and the exact EIP-3009 authorization with Intercepta and decides PAY / CAP / HOLD / REFUSE (how). Only on PAY or CAP does the card approve the payment on-chain; the service then settles it and the agent prints the report. The card page shows the purchase and the USDC left. So one card shows Intercepta twice: the merchant check at issue, and the payment screening at every purchase.
A multi-use card can carry plugins that run before every purchase (see SPEC.md, "Mode B — plugins"). The first one,
ApprovalHook, holds any single purchase above a threshold until you approve that exact purchase:
- Open the app at
http://localhost:5173(not127.0.0.1: passkeys don't work on IP addresses). - Issue a multi-use card for teamLab Borderless and tick Ask for my approval before big purchases (big means over
0.005by default). Leave Approve with Touch ID on, then Review and issue and issue the card (withoutINTERCEPTA_API_KEYthe merchant check is "unverified": tick the risk box and Issue anyway). The first time, the browser asks you to create a passkey. The card shows "Touch ID over 0.005 ETH". npm run agent -- <card> "buy one adult ticket"goes through on its own.npm run agent -- <card> "buy 3 adult tickets"is Held. The agent waits (up to 5 minutes) and the card page shows the purchase, decoded from the agent's order, with Approve with Touch ID.- Touch the sensor. The signature is checked on-chain, the agent retries the same order, and it's Bought. Activity reads Held → You approved with Touch ID → Bought.
An approval covers that one purchase, once, for an hour. The app's own account can't approve a Touch ID card; only the passkey can. Untick Approve with Touch ID to have the owner account approve instead (no passkey needed). The threshold applies per purchase, so an order split into small ones isn't held; the card's budget and uses still cap it.
The passkey is kept in your browser's keychain, and its id and public key in this browser's local storage, so approve in the browser you issued the card from. Use a new passkey on the issue form starts over; cards issued with the old passkey then say so on their page instead of asking for Touch ID. If nobody approves while the agent waits (5 minutes), the purchase shows as "not approved while the agent waited" and the Approve button goes away: run the agent again.
Agents pay x402 services in USDC on Base Sepolia from a ReusablePermissionWallet. Every payment is screened live by
the Intercepta API and the verdict — PAY, CAP, HOLD or REFUSE, with reasons — decides what happens.
- Paying agent: before signing, screens
payTo, the token (real USDC vs lookalike) and the EIP-3009 authorization, then the wallet contract enforces budget/uses/expiry inapprovePaymentand accepts the signature via ERC-1271. - Paid service: an x402 server with its own facilitator screens the payer wallet, its owner and its agent before verifying or settling.
- Counterparty risk: every wallet on the other side gets a profile (TRUSTED / CAUTION / BLOCKED) with Intercepta's reasons.
Payments run against Base Sepolia's real USDC contract, either on a local Anvil fork (npm run demo) or on the public testnet. Screening uses the same addresses' mainnet history (Intercepta only covers mainnets). Contract behaviour is specified in SPEC.md.
packages/risk/src/intercepta.ts— the only HTTP client (quick scan, deep scan, summarize, token, message)apps/agent/src/x402/screen.ts+guarded-signer.ts— payer gate, runs beforeapprovePayment/signingapps/service/src/payer-gate.ts— payee gate, runs before facilitator verify/settlepackages/risk/src/policy.ts— how results become PAY / CAP / HOLD / REFUSEapps/web/server/screening.ts— merchant check when issuing a card (dev-server endpoint)
The quickest way to see it work. It's the same npm run demo as above, with INTERCEPTA_API_KEY in .env:
npm install
npm run demo # fork, deploy, fund, start service + agent daemon + UI
npm run demo -- --scenarios # same, plus the scripted four-scenario demoThe launcher forks Base Sepolia into a local Anvil chain, so it's the real USDC contract (FiatToken v2.2) on chain id 84532. It deploys the demo contracts (the wallet factory plus the card contracts, so the card pages work too), creates fresh throwaway owner/agent/facilitator/payee keys, funds them on the fork (ETH plus USDC via anvil_dealERC20), creates the two demo wallets, and starts the x402 service, the weather service, the agent daemon and the UI at http://localhost:5173 (open http://localhost:5173/payments). Screening still calls Intercepta live against mainnet data. RISKY_PAYTO/RISKY_OWNER come from .env. If they're unset, the launcher uses two addresses that Intercepta tiers BLOCKED for different reasons: the risky seller is 0x3930…2fed, an Intercepta test address flagged as a known scammer that received funds from exploits and drainers; the risky wallet's owner is 0x098B…2f96, the OFAC-sanctioned Ronin bridge exploiter. Settlement tx links point at basescan, but local fork transactions only exist on your Anvil chain.
The keys are fresh on every run because Intercepta rejects Anvil's well-known dev addresses with a 404 ("An Externally Owned Account with this address doesn't exist"). The fail-closed rule would otherwise refuse every payment.
Prerequisites (manual, one-time):
- An Intercepta API key: free at intercepta.io/ethglobal
- Risky test addresses to use as
RISKY_PAYTO/RISKY_OWNER: pinned in Intercepta's ETHGlobal Discord - Base Sepolia ETH on the owner, agent and facilitator keys (any Base Sepolia faucet)
- ~1.2 USDC on the owner key: faucet.circle.com
Once you have an Intercepta key and a risky/clean address pair, sanity-check the API before wiring up the full demo:
npm --workspace @eaw/risk run smoke -- <riskyAddress> <cleanAddress>See packages/risk/scripts/smoke.ts — it's the first live call against Intercepta and prints the raw response shapes.
With .env filled in (see .env.example):
set -a; source .env; set +a # export .env so forge sees $RPC_URL / $OWNER_PRIVATE_KEY
cd packages/contracts && forge script script/DeployX402.s.sol:DeployX402 --rpc-url $RPC_URL --broadcast --private-key $OWNER_PRIVATE_KEY
# put FACTORY_ADDRESS in .env, then:
npm --workspace @eaw/agent run x402:setup # put printed WALLET_ADDRESS / RISKY_WALLET_ADDRESS in .env
npm --workspace @eaw/service start & # terminal 1
npm --workspace @eaw/agent run x402:demoExpected output:
verdict: PAY status: settledwith a basescan link.verdict: REFUSE status: refusedwith Intercepta trait reasons (e.g.sanction_address).verdict: HOLD status: held(above_hold_threshold), then 3bPAY … settledwithowner_approved.verdict: PAY status: rejected_by_payeewithpayer_refused: owner 0x…: <trait descriptions>.
If 1 fails at the facilitator with a signature error, confirm the signature is 96 bytes and verifyTypedData is the viem public action (ERC-1271 capable).
Then run the UI flow: npm --workspace @eaw/agent run daemon, npm run web, open http://localhost:5173/payments (the Payments page), and repeat 1–4 with the buttons, approving the hold from the inbox.
Origins must match exactly (localhost and 127.0.0.1 are different origins): open the UI at the same origin as
AGENT_UI_ORIGIN (the daemon rejects POSTs from any other origin, or with no Origin at all, and any Host other
than localhost/127.0.0.1 on its port), and set VITE_SERVICE_URL to the same origin as SERVICE_URL. The service
only allows cross-origin reads from SERVICE_UI_ORIGIN (defaults to AGENT_UI_ORIGIN).
- The permission budget is consumed when the agent approves a payment on-chain, not when it settles.
- An approved-but-unsettled authorization survives a revoke until its
validBefore(the agent refuses windows over 15 minutes). createWalletForon the factory is permissionless — fine for the demo, not for production. It emitsWalletCreatedFor(with the creator), notWalletCreated, so it can't pass for the owner's own wallet.- A payment that was approved on-chain but not confirmed as settled shows as Not confirmed (
unsettled): the budget is spent and the seller can still settle it untilvalidBefore. - The service screens the paying wallet reliably, but the owner and agent it screens are whatever the wallet contract reports about itself; a hostile contract wallet can report clean ones.
- Screening fails closed: an Intercepta timeout, error or unexpected response refuses the payment. Intercepta also answers 404 ("An Externally Owned Account with this address doesn't exist") for some addresses, such as Anvil's well-known dev accounts, so those counterparties are refused too.
npm run demoruns the cards on the same fork (chain 84532), so the card pages andnpm run agentwork there. The web app reads events only from the block after the fork point (VITE_FROM_BLOCK): earlier blocks would be fetched from the public Base Sepolia RPC.
- Time to first call: minutes once we had the key. A plain
X-API-KEYheader and clear OpenAPI pages made it easy; our 7-call smoke run (packages/risk/scripts/smoke.ts) takes about 9 s end to end. - Confusing: Scan Message's documented
messageTypeenum has noTransferWithAuthorization(EIP-3009, what x402 signs), yet the endpoint accepts it and returns ariskGroup. We only found that out by trying. - Confusing: the trait
riskscale isn't documented. Live responses show 0–100 with fractional values (e.g.fake_phishing_transferat 0.54), so we had to guess thresholds. - Missing: Scan Message rated a transfer to a sanctioned address as
Low. It doesn't factor in the recipient's own risk, so we screenpayToseparately with the address scans. - Missing: no testnet chain ids. x402 runs on testnets, so we rewrite the EIP-712 domain to Base mainnet (chain 8453, mainnet USDC) purely for screening.
npm install
npm test # vitest in packages/risk, apps/agent, apps/service
npm --workspace @eaw/web run build # vite build + type-check
npm --workspace @eaw/agent run typecheck
cd packages/contracts && forge test # contract tests; the Base Sepolia fork test is skipped...
BASE_SEPOLIA_RPC_URL=https://sepolia.base.org forge test --match-contract X402ForkTest # ...unless this is setCI (.github/workflows) runs the same: npm test, the web build, the agent type-check and forge test.
If the web app crashes on start after pulling (for example a React version error), an old untracked
package-lock.json is likely pinning stale dependencies: rm -rf node_modules package-lock.json && npm install.
A mock web service that sells a Mount Fuji weather report behind x402, for $0.01 in USDC on Base Sepolia. It's a second, independent seller for the agent.
npm run demo starts it on the fork with a fresh payee and its own facilitator key (WEATHER_FACILITATOR_PRIVATE_KEY), so it settles in-process like the x402 service, and lists it as a card merchant (A card for an x402 seller). The card agent finds it at WEATHER_URL (default http://localhost:4022/weather/mount-fuji). The weather service itself doesn't screen payers.
To run it on its own, set WEATHER_PAY_TO in .env to the address that receives payments, then:
npm run weather
curl -i http://localhost:4022/weather/mount-fuji # 402 Payment RequiredWithout WEATHER_FACILITATOR_PRIVATE_KEY it settles through the public facilitator at https://x402.org/facilitator on the public testnet. To make a paid request, use any x402 client (for example @x402/fetch) with a wallet holding Base Sepolia USDC from the Circle faucet. The report is random mock data. WEATHER_PORT changes the port.
SPEC.md: source of truth for contract behaviorpackages/contracts: wallets, factories, the plugin interface andApprovalHook, demo merchants, tests and deployment scripts (Deploy.s.sol,DeployX402.s.sol)packages/shared: ABIs and revert decoding shared by the app and the agentpackages/risk: Intercepta API client, wallet/counterparty profiling, PAY/CAP/HOLD/REFUSE policy (@eaw/risk)apps/agent: agent CLI with the Claude and offline planners; also the x402 pay loop, hold queue and daemon API (src/x402/)apps/service: x402-paid API with an Intercepta payer gate in front of its facilitatorapps/weather: mock x402 service selling Mount Fuji weather reportsapps/web: React app (TanStack Router and Query, wagmi, shadcn/ui) for cards and activity, plus the x402 payments page (/payments)scripts/demo.mjs: local demo orchestrator (cards + x402 on an Anvil fork of Base Sepolia)
The MVP deliberately uses native ETH and a local Anvil chain for the one-time and multi-use cards. On top of that,
apps/agent and apps/service add a live x402 payment flow in USDC on Base Sepolia, screened end-to-end by Intercepta
(see "Safe agent-to-agent payments" above). Real DeFi targets and ERC-4337/session keys come next.