Skip to content

Example: pre-pay check of an x402 endpoint in a Mastra agent #3

Backlog

Description

@agent402-dev

/reward 50

Add a small, runnable Mastra example that checks an x402 paid endpoint before anything pays for it.

What it should do

  • A Mastra tool (createTool) that calls runCheck402({ url }) from @agent402-dev/ai-sdk-tools and returns its result. One request, no payment header, nothing signed or paid, no key read.
  • The agent's instructions say: do not pay when fixes > 0.

Where

examples/mastra-prepay-check/: README.md, package.json with pinned versions, src/index.ts.

Done when

  • npm install && npm start -- https://<a live x402 endpoint> prints the agent's answer with the price and fixes: 0; against a local broken 402 the agent says it will not pay.
  • README: install, run, result fields, one line that nothing is paid, the Mastra and model versions used.
  • No wallet, key or RPC needed (an LLM key is fine).

Bounty rules

  • Paid only for a pull request that is merged into this repository. Partial work or closed PRs are not paid.
  • Comment /try before you start. If two people work on it, the first PR that meets every item above and is merged gets the bounty.
  • Not eligible: maintainers of this repository and people related to them.
  • Out of scope for any bounty: changes to payment code, payment rules or limits, keys, wallets or signing. A PR that touches them is not merged under this bounty.
  • Open your PR with /claim #<this issue number> in the description.
  • Payment is arranged directly with you after the merge (Opire does not pay automatically). The amount and the date it was paid are posted in this issue.
  • AI tools are fine; you must have run the example yourself and say which versions you used.


This repo is using Opire - what does it mean? 👇
💵 Everyone can add rewards for this issue commenting /reward 100 (replace 100 with the amount).
🕵️‍♂️ If someone starts working on this issue to earn the rewards, they can comment /try to let everyone know!
🙌 And when they open the PR, they can comment /claim #3 either in the PR description or in a PR's comment.

🪙 Also, everyone can tip any user commenting /tip 20 @agent402-dev (replace 20 with the amount, and @agent402-dev with the user to tip).

📖 If you want to learn more, check out our documentation.

Activity

  1. ArtyormSatori commented on Dec 5, 2026

    @ArtyormSatori

    /try

    Check if you're the only one trying 👇
    You're the first one to try to solve this issue, go for it! 😉

  2. mugi-works-2026 commented on Dec 5, 2026

    @mugi-works-2026

    /try

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributor is: @ArtyormSatori.

  3. killdabeat91 commented on Dec 5, 2026

    @killdabeat91

    /try

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @mugi-works-2026.

  4. IlhamEl777 commented on Dec 5, 2026

    @IlhamEl777

    /try

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @mugi-works-2026 @killdabeat91.

  5. lonely358 commented on Dec 5, 2026

    @lonely358

    /try

    Starting on this. Plan: add examples/mastra-prepay-check/ with a Mastra tool (createTool) calling runCheck402({ url }) from @agent402-dev/ai-sdk-tools, agent instructions to not pay when fixes > 0. Will verify with npm install && npm start -- <live x402 endpoint> (expecting price + fixes: 0) and against a local broken 402 (agent refuses to pay), plus README with install/run steps and pinned versions.

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @mugi-works-2026 @killdabeat91 @IlhamEl777.

  6. pythonyx135793 commented on Dec 5, 2026

    @pythonyx135793

    /try

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @mugi-works-2026 @killdabeat91 @IlhamEl777 @lonely358.

  7. opirebot commented on Dec 5, 2026

    @opirebot

    🎉 The user @killdabeat91 has claimed all rewards for this issue.
    🔍 You can see the PR here.
    💸 @agent402-dev

  8. rumangsanya commented on Dec 5, 2026

    @rumangsanya

    /try

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @pythonyx135793 @mugi-works-2026 @killdabeat91 @IlhamEl777 @lonely358.

  9. opirebot commented on Dec 5, 2026

    @opirebot

    🎉 The user @IlhamEl777 has claimed all rewards for this issue.
    🔍 You can see the PR here.
    💸 @agent402-dev

  10. opirebot commented on Dec 5, 2026

    @opirebot

    🎉 The user @rumangsanya has claimed all rewards for this issue.
    🔍 You can see the PR here.
    💸 @agent402-dev

  11. riccardocens-code commented on Dec 5, 2026

    @riccardocens-code

    /try

    I'll add examples/mastra-prepay-check/: a Mastra createTool tool that calls runCheck402({ url }) from @agent402-dev/ai-sdk-tools, an agent that won't pay when fixes > 0, a local broken-402 server, and a README with package.json pinned versions. I'll run it against a live endpoint and the local server.

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @pythonyx135793 @mugi-works-2026 @killdabeat91 @IlhamEl777 @lonely358 @rumangsanya.

  12. opirebot commented on Dec 5, 2026

    @opirebot

    🎉 The user @riccardocens-code has claimed all rewards for this issue.
    🔍 You can see the PR here.
    💸 @agent402-dev

  13. opirebot commented on Dec 5, 2026

    @opirebot

    🎉 The user @Vee-Git has claimed all rewards for this issue.
    🔍 You can see the PR here.
    💸 @agent402-dev

  14. princeofchaos commented on Dec 5, 2026

    @princeofchaos

    /try

    Check if you're the only one trying 👇
    There are already people trying to solve this issue. You're welcome to tackle it independently, but we encourage you to reach out to the contributors that are trying to solve the issue if you'd like to collaborate with them.

    The other contributors are: @ArtyormSatori @Vee-Git @pythonyx135793 @mugi-works-2026 @killdabeat91 @IlhamEl777 @lonely358 @rumangsanya @riccardocens-code.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions