Skip to content

tools: BaseTokenGate — read-only pre-trade safety check for arbitrary Base tokens - #214

Closed
rezearcher wants to merge 3 commits into
BlockRunAI:mainfrom
rezearcher:feat/base-token-gate
Closed

rezearcher wants to merge 3 commits into
BlockRunAI:mainfrom
rezearcher:feat/base-token-gate

Conversation

@rezearcher

@rezearcher rezearcher commented Oct 19, 2026 •

Copy link
Copy Markdown

Follow-up to #213. Instead of just suggesting a gate, here's a small, self-contained, read-only tool so you can judge it on the code.

What: BaseTokenGate — before Base0xQuote into a token that isn't in the built-in symbol list, the agent calls this to get a one-word GO / HOLD / BLOCK + reason (honeypot/sellability simulation, admin-control checks, Uniswap v3 liquidity vs. trade size). Backed by Grey Ridge's x402 endpoint GET https://api.greyridgesignals.ai/gate/swap.

Design (matches existing conventions):

  • Same x402 handshake as exa.ts (createPaymentPayload from @blockrun/llm), $0.008 USDC/call from the Base wallet, recorded via recordUsage.
  • 402 branch is gated on walletMayPay(gatewayHeaders()), so key-mode users never get a wallet signature (the repo's api-key.local.mjs fence passes).
  • Output wrapped with frameUntrusted (third-party data, not instructions).
  • Read-only, no new deps, fail-open: transport errors return "unchecked" and never block a trade by themselves. Base chain only (returns an error on Solana).
  • Endpoint overridable with FRANKLIN_TOKEN_GATE_URL.
  • tsc --noEmit clean; npm test 918/918 pass locally. 2 files, ~140 lines.

Try it without paying: curl 'https://api.greyridgesignals.ai/gate/swap/preview?token=aero' (free samples for usdc|weth|cbbtc|aero|degen); the paid route works for any Base ERC-20.

Happy to rename, drop the payment path and ship it as free-preview-only, or change anything else you'd like. Disclosure: I run the endpoint.

🤖 Generated with Claude Code

@VickyXAI

VickyXAI commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR and for disclosing that you run the endpoint. We're closing this one rather than merging it.

The main issue: the tool signs whatever amount and recipient the endpoint's 402 response asks for, while recordUsage always logs a fixed $0.008. So spend caps can't see what is actually paid, and users' USDC would go straight to a third-party host outside the BlockRun gateway. Franklin's position is that paid calls go through the gateway and its spend controls, so we don't want to open a direct-to-vendor payment path.

If you'd like to offer the token gate to Franklin users, the way in is to list it as a partner API on the BlockRun gateway, so it is paid and capped like every other tool. We're happy to talk about that.

(Separately: the PhoneLookup and RealFace comments in src/tools/index.ts were changed to $0.008, but both still charge $0.01.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants