x402 r&d for infra and test api
x402 is an early-stage Go project in the AI payments / x402 ecosystem, focused on agents, blockchain, coinbase, llm. It currently has 0 GitHub stars and 0 forks, and sits alongside related tools like x402, gold-402, x402.
Repository: github.com/denizumutdereli/x402
This repository contains a self-hosted x402 infrastructure foundation built in Go.
The current implementation is designed to reuse the upstream coinbase/x402/go protocol logic instead of reimplementing payment verification, signing, and settlement rules from scratch. This repository adds an application and infrastructure layer around that core: service composition, configuration, HTTP APIs, trusted setup registration, and testable local development flows.
This project is currently a working foundation, not a fully finished production platform.
At the moment, the repository includes:
This monorepo provides the infrastructure and application shell around x402:
The core payment protocol behavior is intentionally reused from upstream libraries, especially:
In other words: this repository owns the infra/application composition, while upstream owns most of the protocol-critical x402 logic.
.
├── cmd/
│ ├── facilitator/
│ └── resource-server/
├── configs/
│ ├── facilitator.example.json
│ └── resource-server.example.json
├── e2e/
│ └── e2e_test.go
├── internal/
│ ├── auth/
│ ├── config/
│ ├── facilitator/
│ └── resourceserver/
└── resources/
└── coinbase-x402/
The facilitator is the service responsible for verifying and settling payments.
Main files:
cmd/facilitator/main.gointernal/facilitator/app.gointernal/facilitator/mock_evm.gointernal/facilitator/real_evm.gointernal/facilitator/guard.goResponsibilities:
GET /healthGET /supportedPOST /verifyPOST /settleThe resource server protects application routes and requires x402 payments before returning paid responses.
Main files:
cmd/resource-server/main.gointernal/resourceserver/http.goResponsibilities:
402 Payment Required when payment is missing or invalidMain file:
internal/config/config.goResponsibilities:
Main file:
internal/auth/bearer.goResponsibilities:
Main files:
internal/facilitator/mock_evm.goe2e/e2e_test.goResponsibilities:
The current flow is built around two services:
A client requests a paid endpoint from the resource server. If payment is missing, the resource server responds with x402 payment requirements. The client then creates a payment payload, signs it, and retries the request with x402 payment headers. The resource server sends the payment material to the facilitator for verification. If verification succeeds, the resource server produces the protected response and then asks the facilitator to settle the payment.
The payment is signed by the payer/client signer, not by the facilitator.
In the current test flow, the signer is created using the upstream EVM client signer and signs EIP-712 typed data using the payer private key.
The facilitator verifies that signature and, if everything is valid, executes settlement through the configured trusted setup signer.
Validation happens in multiple layers.
Handled in internal/config/config.go.
This validates:
Handled in internal/facilitator/app.go.
This validates that incoming facilitator API requests contain:
paymentPayloadpaymentRequirementsHandled primarily by upstream x402 EVM exact facilitator logic.
This includes:
There is currently no persistent session store and no user session model.
The only short-lived state currently managed by this repository is a temporary in-memory verify-before-settle guard:
This is useful for a deterministic local flow, but it is not yet a production-grade distributed state model.
sequenceDiagram
autonumber
participant Client
participant ResourceServer
participant Facilitator
participant TrustedSetup as Trusted Setup / Signer
participant Chain as Blockchain / Mock Chain
Client->>ResourceServer: GET /paid-resource
ResourceServer->>ResourceServer: Match protected route
ResourceServer-->>Client: 402 Payment Required + payment requirements
Client->>Client: Build x402 payment payload
Client->>Client: Sign EIP-712 authorization with payer key
Client->>ResourceServer: Retry request with x402 payment headers
ResourceServer->>Facilitator: POST /verify
Facilitator->>TrustedSetup: Verify payload, nonce, balance, signature
TrustedSetup->>Chain: Read state (balance / nonce / code if needed)
Chain-->>TrustedSetup: Current on-chain or mock state
TrustedSetup-->>Facilitator: Verify result
Facilitator-->>ResourceServer: Payment valid
ResourceServer->>ResourceServer: Produce protected response
ResourceServer->>Facilitator: POST /settle
Facilitator->>TrustedSetup: Execute settlement
TrustedSetup->>Chain: Submit transfer / authorization transaction
Chain-->>TrustedSetup: Receipt / success
TrustedSetup-->>Facilitator: Settlement result
Facilitator-->>ResourceServer: Settlement success
ResourceServer-->>Client: 200 OK + paid response + payment response headers
go test ./...
export FACILITATOR_BEARER_TOKEN=secret-token
go run ./cmd/facilitator -config configs/facilitator.example.json
export FACILITATOR_BEARER_TOKEN=secret-token
go run ./cmd/resource-server -config configs/resource-server.example.json
curl -i http://localhost:4021/health
curl -i http://localhost:4021/weather
Expected behavior:
GET /health returns 200 OKGET /weather returns 402 Payment Required unless a valid x402 payment is attachedThe current test coverage proves the following foundation behavior:
The current end-to-end test covers:
resources/coinbase-x402/examples/go/servers/custom/main.goresources/coinbase-x402/go/http/server.goresources/coinbase-x402/go/http/client.goresources/coinbase-x402/go/http/facilitator_client.goresources/coinbase-x402/go/mechanisms/evm/exact/server/scheme.goresources/coinbase-x402/go/mechanisms/evm/exact/facilitator/scheme.goresources/coinbase-x402/go/signers/evm/client.goresources/coinbase-x402/go/types.goresources/coinbase-x402/go/types/v2.goThis repository currently gives you a working x402 infrastructure foundation in Go:
It is intentionally built to reuse upstream x402 payment mechanics instead of reinventing them, while adding the monorepo structure needed for application composition, local testing, and future production hardening.
💸 Enable seamless, low-cost digital dollar payments with x402—zero fees, instant settlement, and no high minimums for all users.
⚡ The gold standard for x402 resources. 300+ projects, SDKs, tools, facilitators, and ecosystem data for the HTTP 402 Payment Required protocol. Curated by 24K Labs.
💸 Simplify payments with x402, an open protocol for fast, fee-free digital dollar transactions. Experience seamless integration and instant settlements.
Your AI trading terminal assistant for US stocks, commodities, forex, and crypto.
Golang SDK for A2A Protocol
Publishes localhost services to the agentic web through self-hostable, trustless relays with x402 payments.
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Building blocks for Agentic payments (x402, MPP, AP2) for TypeScript, Rust, Go, Python, Ruby, PHP, Lua, Kotlin and Swift.
Go implementation of the x402 payment protocol