x402 Execution Middleware — Stripe Webhooks for x402. Agent-ready payment infrastructure for the x402 ecosystem.
TripWire is an early-stage Python project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.
Programmable onchain event triggers for AI agents.
Goldsky tells you what happened. TripWire decides if it's safe to act. Convoy makes sure you hear about it.
Turn onchain events into safe execution signals -- instantly or after finality. TripWire is the infrastructure layer between onchain events and application execution: it indexes, verifies, enriches, and delivers so your application never has to poll a chain or parse a log.
TripWire runs as a dual-product platform:
trigger.matched -> trigger.confirmed -> trigger.finalized.transferWithAuthorization micropayments with a ~100ms facilitator fast path. Supports sessions -- pre-authorized spending limits so agents can make multiple MCP tool calls without per-call x402 payment negotiation.Deploy as Pulse-only, Keeper-only, or both (default) via the PRODUCT_MODE environment variable.
X-TripWire-Session header instead of per-call x402 payments. Feature-flagged via SESSION_ENABLED.MAX_TRIGGERS_PER_WALLET, MAX_ENDPOINTS_PER_WALLET) prevent runaway resource creation.PROCESS_ROLE=api|worker|all for independent scaling. API instances serve HTTP requests; worker instances run background tasks (finality polling, event bus, sweeper).TripWire's core differentiator: the same event progresses through execution states, and your application decides when to act based on the safe_to_execute flag.
Path Latency execution_state safe_to_execute
─────────────────────────── ────────── ───────────────── ───────────────
Instant (x402 fast path) ~100ms provisional false
Finalized (Goldsky path) ~1-13s finalized true
A single event_id progresses through: pre_confirmed -> confirmed -> finalized
Your webhook receives an update at each stage. Show a spinner on provisional. Commit the transaction on finalized. Roll back on reorged.
L0 Chain Base / Ethereum / Arbitrum (ERC-3009, any EVM event)
|
L1 Goldsky Turbo Indexes events, delivers raw logs via webhook to /ingest
|
L2 TripWire Engine Decode -> Filter -> Payment Gate -> Dedup -> Finality ∥ Identity -> Policy
|
L3 Convoy Delivery HMAC-signed webhooks, 10x retries, backoff, DLQ
|
L4 Your App Receives verified payload, executes business logic
|
L5 MCP Server AI agent interface -- 12 tools for trigger CRUD + discovery via JSON-RPC
Two ingestion paths feed the same pipeline:
| Path | Latency | Source |
|---|---|---|
| Goldsky Turbo | 2-4s | Webhook sink from indexed chain data |
| x402 Facilitator | ~100ms | Pre-settlement hook (fast path) |
Two delivery modes:
| Mode | Transport | Guarantees |
|---|---|---|
| Execute | Convoy webhook POST | HMAC-signed, 10x retry, DLQ, delivery logs |
| Notify | Supabase Realtime push | Lightweight event stream for dashboards |
git clone https://github.com/your-org/tripwire.git
cd tripwire
cp .env.example .env # Fill in Supabase + Convoy credentials
pip install -e ".[dev]"
python dev_server.py # Starts on port 3402 with auth bypass
Verify the server is running:
curl http://localhost:3402/health
# {"status": "ok", "service": "tripwire", "version": "1.0.0"}
The dev server bypasses wallet authentication and uses Hardhat account #0 (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266) so you can test endpoints without signing SIWE messages.
For production:
APP_ENV=production python -m tripwire.main
TripWire exposes 12 tools via the Model Context Protocol at /mcp, enabling AI agents to manage triggers programmatically over JSON-RPC 2.0.
| Tier | Mechanism | Tools |
|---|---|---|
| PUBLIC | None | initialize, tools/list |
| SIWX | Wallet signature | list_triggers, delete_trigger, list_templates, get_trigger_status, search_events, fetch_abi, list_pools, validate_trigger |
| SESSION | Pre-funded budget | Any X402 tool (bypasses per-call payment) |
| X402 | Per-call micropayment | register_endpoint ($0.003), register_middleware ($0.003, deprecated), create_trigger ($0.003), activate_template ($0.001) |
| Tool | Auth | Description |
|---|---|---|
register_endpoint |
X402 | Create a webhook endpoint. Use create_trigger separately for triggers. |
register_middleware |
X402 | (Deprecated) Creates endpoint + triggers. Use register_endpoint instead. |
create_trigger |
X402 | Create a custom trigger for any event signature. |
list_triggers |
SIWX | List your active triggers. |
delete_trigger |
SIWX | Deactivate a trigger (soft delete). |
list_templates |
SIWX | Browse trigger templates from the Bazaar. |
activate_template |
X402 | Instantiate a Bazaar template with custom params. |
get_trigger_status |
SIWX | Check trigger health and recent event count. |
search_events |
SIWX | Query recent events for your endpoints. |
fetch_abi |
SIWX | Fetch contract ABI and list its events. |
list_pools |
SIWX | List popular DeFi protocol pools (aerodrome, aave-v3, uniswap-v3). |
validate_trigger |
SIWX | Validate a trigger configuration before creating it. |
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "register_middleware",
"arguments": {
"url": "https://myagent.example.com/webhook",
"mode": "execute",
"chains": [8453],
"template_slugs": ["x402-payment"],
"custom_triggers": [
{
"event_signature": "Transfer(address,address,uint256)",
"name": "Large USDC transfers",
"contract_address": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
"filter_rules": [{"field": "value", "op": "gte", "value": "1000000000"}]
}
]
}
}
}
Returns endpoint_id, webhook_secret, trigger_ids, mode, and url in a single call.
Every delivery follows the v1 payload schema. The execution_state and safe_to_execute fields are the signals your application logic should branch on.
{
"id": "evt_a1b2c3d4e5f6",
"idempotency_key": "sha256:8453:0x9f86d081...b0f00a08:7",
"type": "payment.finalized",
"mode": "execute",
"timestamp": 1710700800,
"version": "v1",
"execution": {
"state": "finalized",
"safe_to_execute": true,
"trust_source": "onchain",
"finality": {
"confirmations": 3,
"required_confirmations": 3,
"is_finalized": true
}
},
"data": {
"transfer": {
"chain_id": 8453,
"tx_hash": "0x9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08",
"block_number": 28451023,
"from_address": "0x1234567890abcdef1234567890abcdef12345678",
"to_address": "0xabcdefabcdefabcdefabcdefabcdefabcdefabcd",
"amount": "5000000",
"nonce": "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
"token": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
},
"identity": {
"address": "0x1234567890abcdef1234567890abcdef12345678",
"agent_class": "payment-agent",
"deployer": "0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef",
"capabilities": ["x402-payment", "erc3009-transfer"],
"reputation_score": 87.5,
"registered_at": 1706572800,
"metadata": {}
}
}
}
Key fields:
| Field | Values | Meaning |
|---|---|---|
execution.state |
provisional, confirmed, finalized, reorged |
How far the event has progressed |
execution.safe_to_execute |
true / false |
true only after onchain finality confirmed |
execution.trust_source |
facilitator or onchain |
Who vouches for this state |
idempotency_key |
Deterministic SHA-256 | Safe to deduplicate on your end |
Event types: payment.pre_confirmed, payment.confirmed, payment.finalized, payment.failed, payment.reorged
UNIQUE constraint on (chain_id, nonce, authorizer) with atomic upsert. The same transfer cannot be processed twice.policies.finality_depth.payment.reorged events so your application can roll back provisional actions.| Document | Description |
|---|---|
| Architecture | System design, layer breakdown, data flow |
| API Reference | REST endpoint specifications |
| Webhooks | Payload formats and delivery semantics |
| MCP Server | MCP tools, authentication tiers, and pricing |
| Security | Auth model, HMAC signing, threat model |
| Operations | Deployment, monitoring, DLQ handling |
| Development | Local setup, testing, contribution guidelines |
| Skill Spec (TWSS-1) | Execution-aware skill standard |
| Team Update | Latest sprint summary and known issues |
TripWire uses a unified decoder abstraction to process all event types through a single pipeline:
| Phase | Status | Description |
|---|---|---|
| C1 | Done | Decoder protocol + DecodedEvent envelope + ERC3009Decoder + AbiGenericDecoder |
| C2 | Done | Unified processing loop -- single code path for ERC-3009 and dynamic triggers (feature-flagged via UNIFIED_PROCESSOR) |
| C3 | Done | Per-trigger payment gating via decoder metadata (require_payment, payment_token, min_payment_amount) |
When UNIFIED_PROCESSOR=true, dynamic triggers gain finality checking, full policy evaluation, execution state metadata, notify mode, tracing, and metrics -- all features previously exclusive to the ERC-3009 path.
| Component | Technology |
|---|---|
| Runtime | Python 3.11+ |
| API Framework | FastAPI + Uvicorn |
| Database | Supabase (managed PostgreSQL) |
| Webhook Delivery | Convoy (self-hosted) + direct httpx fast path |
| Blockchain Indexing | Goldsky Turbo |
| Event Bus | Redis Streams (optional, for horizontal scaling) |
| RPC | httpx (raw JSON-RPC calls, no web3.py) |
| ABI Decoding | eth-abi |
| Validation | Pydantic v2 |
| Logging | structlog (structured JSON) |
| Metrics | Prometheus |
| Tracing | OpenTelemetry (optional) |
| Error Tracking | Sentry (optional) |
| Agent Identity | ERC-8004 onchain registry |
| Payments | x402 protocol (ERC-3009 transferWithAuthorization) |
Proprietary. All rights reserved. See LICENSE for details.
The living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
The living ecosystem where AI agents complete tasks through workflow loops, improve through iterative execution, are evaluated by mentor agents or humans in the loop, and turn completed work into reusable work experience and data to improve future agents.
Self-healing infrastructure for AI agent payments. 90.3% auto-recovery.
The first agentic payment network: policy-controlled, gasless, and real money-ready. OmniClaw CLI + Financial Policy Engine let autonomous agents pay and earn safely at machine speed.
The A2A x402 Extension brings cryptocurrency payments to the Agent-to-Agent (A2A) protocol, enabling agents to monetize their services through on-chain payments. This extension revives the spirit of HTTP 402 "Payment Required" for the decentralized agent ecosystem.
DePIN for Vintage Hardware — Proof-of-Antiquity blockchain where old machines outmine new ones. AI-powered hardware fingerprinting, 15+ CPU architectures, Solana bridge (wRTC). $0 VC.