Skip to content

docs(examples): add x402ActionProvider pre-execution safety guard example - #1417

Open
teodorofodocrispin-cmyk wants to merge 1 commit into
coinbase:mainfrom
teodorofodocrispin-cmyk:add-x402-sentinel-preflight-guard-example
Open

docs(examples): add x402ActionProvider pre-execution safety guard example#1417
teodorofodocrispin-cmyk wants to merge 1 commit into
coinbase:mainfrom
teodorofodocrispin-cmyk:add-x402-sentinel-preflight-guard-example

Conversation

@teodorofodocrispin-cmyk

Copy link
Copy Markdown

What this adds

A minimal, standalone example demonstrating a pattern: gating an on-chain transaction behind a third-party x402 safety check, using the existing x402ActionProvider -- no new dependencies added to the framework itself.

The pattern

  1. Build the candidate transaction (to, value, data).
  2. Call an x402-compatible guard/safety service via makeHttpRequestWithX402 (pays the small USDC fee automatically).
  3. Only proceed to sign/execute if the verdict is safe.

This is deliberately not wired through the LLM tool-calling loop for the safety decision itself -- the check should run every time, deterministically, regardless of what the model decides. The example calls the action provider's methods directly in code.

About the third-party service used in the example

The example uses SENTINEL as the guard service purely because its response (verdict / risks / score) is easy to branch on for a clear example. It is independent and unaffiliated with Coinbase/AgentKit -- I'm one of its maintainers, flagging that plainly. The pattern generalizes to any x402-compatible guard service; swapping GUARD_URL and the response-parsing is enough. Happy to genericize this further (e.g. parameterize the guard URL/schema) if that's preferred to naming one service in an official example.

Verification

  • TypeScript syntax/type-checks cleanly in isolation (tsc --noEmit --skipLibCheck) -- no errors beyond expected unresolved workspace (@coinbase/agentkit) and external (dotenv) packages, which I don't have installed outside the monorepo.
  • I was not able to run this against the full monorepo build/lint/test pipeline from my environment. Structure (package.json, tsconfig.json, eslint/prettier configs) mirrors typescript/examples/langchain-cdp-chatbot as closely as possible for consistency, but please flag anything that doesn't match current conventions -- glad to adjust.

Files added

typescript/examples/x402-sentinel-preflight-guard/

  • guard-before-transfer.ts -- the example itself
  • README.md
  • package.json, tsconfig.json, .eslintrc.json, .prettierrc, .prettierignore, .env-local

…mple

Adds a minimal, standalone example showing how to gate an on-chain transaction behind a third-party x402 safety check using the existing x402ActionProvider (no new dependencies on the framework itself).

The pattern: build the candidate tx, call an x402-compatible guard service via makeHttpRequestWithX402 (auto-pays the small USDC fee), and only proceed if the verdict is SAFE. Deterministic -- does not depend on the LLM choosing to run the check.

Uses SENTINEL (sentinel-agent.dev), an independent/unaffiliated x402 service, purely as a worked example since its response is easy to branch on. The pattern generalizes to any x402-compatible guard service -- swapping GUARD_URL is enough.

Verified: TypeScript syntax/type-checks cleanly in isolation (no errors beyond expected unresolved workspace/external packages, which aren't installed outside the monorepo). Not run against the full monorepo build/lint pipeline from this environment -- happy to adjust to match conventions on review.
@cb-heimdall

Copy link
Copy Markdown

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 1
Sum 2

@github-actions github-actions Bot added documentation Improvements or additions to documentation example New example agent typescript labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation example New example agent typescript

Development

Successfully merging this pull request may close these issues.

2 participants