Skip to main content

x402-go Overview

x402-go is a Go implementation of the x402 protocol, enabling verifiable on-chain payments. The project provides comprehensive tools for payment verification and settlement across blockchain networks.

What is x402?

The x402 protocol (as defined by Coinbase) facilitates cryptographically verifiable payment transactions. It enables services to require and validate payments before granting resource access, creating a trustless payment verification system.

Components

Facilitator Service

The backend payment processor providing three main endpoints:

  • GET /supported - Lists available payment scheme-network combinations
  • POST /verify - Validates payment payloads
  • POST /settle - Finalizes payments on blockchain

Facilitator Client

A library for interacting with x402 facilitator services:

  • Query supported payment schemes and networks
  • Verify payment authenticity and validity
  • Settle payments and obtain transaction confirmations

Middleware

Gin-based middleware for protecting HTTP APIs with payment requirements:

  • Define default payment requirements per route
  • Automatically validate incoming x402 payment headers
  • Enforce selective protection on specified paths

Resource Client

Consumer-facing library enabling explicit payment flow management:

  • Detect payment requirements
  • User-driven decision-making on payment acceptance
  • Automated payment transmission with settlement confirmation

Use Cases

  • API Monetization - Require payment for API access without traditional subscription models
  • Pay-per-Use Services - Charge users per request or resource access
  • Content Gating - Require payment before serving premium content
  • Microservices - Enable payment requirements between services

Source Code

View the source code and contribute on GitHub: vorpalengineering/x402-go