Skip to content

feat(examples): add Mastra pre-pay check for an x402 endpoint - #15

Open
Vee-Git wants to merge 1 commit into
agent402-dev:mainfrom
Vee-Git:bounty/3-fix
Open

Vee-Git wants to merge 1 commit into
agent402-dev:mainfrom
Vee-Git:bounty/3-fix

Conversation

@Vee-Git

@Vee-Git Vee-Git commented Dec 5, 2026

Copy link
Copy Markdown

/claim #3

Adds examples/mastra-prepay-check/: a Mastra agent with one createTool (id: 'check402') that calls runCheck402({ url }) from @agent402-dev/ai-sdk-tools. One request without a payment header; nothing is signed or paid; no wallet, key or RPC is used. The agent's instructions say not to pay when fixes > 0.

  • src/index.ts: the tool, the agent and its instructions, and a CLI entry that takes the URL. --allow-local is opt-in because the tool refuses localhost by default.
  • package.json + package-lock.json: exact versions (@mastra/core 1.87.0, @agent402-dev/ai-sdk-tools 0.1.0, @ai-sdk/openai-compatible 3.0.100, zod 4.6.7; Node 22.13+, which @mastra/core requires).
  • README.md: install, run, result fields, the local broken 402 case, and the versions used.

Verified on 2026-12-05 with Node 24.15.0 and model gemini-3.5-flash via Google's OpenAI-compatible endpoint (LLM_BASE_URL / LLM_MODEL), from a clean npm install:

  • npm start -- https://agent402-check402.agent402-ebc.workers.dev/x402/check402 -> fixes: 0. The endpoint returned a valid x402 payment header with no fixes required. price: 0.01 USDC on Solana, 0.01 USDC on Base.
  • against a local 402 without a PAYMENT-REQUIRED header (--allow-local): fixes: 1. I will not pay this endpoint. The finding reported: HTTP 402 without a PAYMENT-REQUIRED header.
  • tsc --noEmit on src (strict) passes.

Not verified: the default gpt-5-mini on api.openai.com (no OpenAI key available here), and no endpoint other than Google's OpenAI-compatible API was run. Nothing was paid in any run; runCheck402 only reads the 402 answer.

AI help: written with an AI assistant (Hermes); the diff was reviewed before submission.

@opirebot

opirebot Bot commented Dec 5, 2026

Copy link
Copy Markdown

👀 We've notified the reward creators here.

This branch has not been deployed

No deployments
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.

1 participant