BeforeCoin

AI agents can't trade or pay until independent checkers sign off. No signature, no transaction.

BeforeCoin

Created At

ETHGlobal Mumbai

Project Description

AI agents now hold real money, and a hijacked agent will spend it just as happily as a healthy one. Most safety tools warn the agent and then let it decide. BeforeCoin takes that decision away from the agent: the check happens before any coin moves.

How it works:

  1. You set the limits. Trade size, tokens, payees and price impact live on your agent's ENS name.
  2. The agent asks first. It sends the exact swap or payment it wants to make.
  3. Three checkers look separately. Each reads live chain data and applies fixed rules. Missing data means no. An AI model can explain or veto, but it can never approve.
  4. Two of three must sign. The signature covers that one action only, so it can't be reused or changed.
  5. The chain enforces it. Without the signatures, a Uniswap v4 hook rejects the swap and the agent's wallet rejects the payment.

Big trades need more. You approve that one action with World ID, and a Chainlink CRE workflow re-checks the facts before the trade can go through.

Try it: the dashboard has an attack lab where you can run each attack, such as a prompt injection or a fake pool, and watch it get refused.

How it's Made

Contracts (Solidity, Foundry): a Uniswap v4 hook checks the signatures in beforeSwap and uses IMsgSender through our router to see who really called. A hook only protects its own pool, so the agent's smart account is the real enforcer. It refuses other pools and direct transfers, and it holds a signed minimum output and a daily spend cap that no server can override.

Payments (x402): the smart account pays per check with Circle USDC. Verifier signatures are packed into its ERC-1271 signature, so a payment nobody cleared simply fails.

Limits (ENSv2): each agent gets a name with its own resolver, and the checkers read limits through ENSIP-10. A writer can be limited to a single record.

Human approval (World ID): a fresh login whose nonce is tied to the exact action, so an approval can't carry over to another trade.

Second check (Chainlink CRE): a TypeScript workflow re-derives the limits and market on chain, compares ETH/USD from CoinGecko, CoinMarketCap and Coinbase using keys held as CRE secrets, then writes its finding on chain. The hook refuses large trades until it exists.

Model review (0G): verifiers can run their optional model review on 0G Private Computer and record the request ID. A model can veto but never approve.

For agents: REST, MCP and x402 access, plus an agent skill in skills/beforecoin. Off chain it's TypeScript with Hono and viem, plus a React dashboard.

The hacky part: a review showed anyone could open a pool on our hook at a fake price and get it approved. We reproduced it, then added a pool creator gate and an owner allowlist in ENS.

Testing: 60 Foundry tests, 352 TypeScript tests, 30 CRE tests on the SDK's mock runtime, and 14 fork tests running every attack against the real Sepolia PoolManager, ENSv2 and USDC.

Status: not yet deployed on real Sepolia. cre workflow simulate hasn't succeeded yet, World ID has only run against a local test issuer, 0G has only run against a mock, and there's no audit. AI wrote almost all of the code, and AI_USAGE.md lists this by part.

background image mobile

Join the mailing list

Get the latest news and updates

BeforeCoin | ETHGlobal