Example servers

Minimal server examples (x402 v1 and v2) and how they integrate with the facilitator

The facilitator repo includes two example integrations:

  • monorepo/facilitator/examples/v1-server/: x402 v1 via x402-express

  • monorepo/facilitator/examples/v2-server/: x402 v2 via @x402/* (Exact EVM scheme)

Common environment variables

Both examples expect:

FACILITATOR_URL=http://localhost:4022
ADDRESS=0x...                # payTo / merchant address
AGENT_PRIVATE_KEY=0x...      # used for registration + signing feedbackAuth hash
DELEGATE_CONTRACT_ADDRESS=0x...

v1 example

v1-server shows:

  • paymentMiddleware(...) protecting GET /resource

  • Generating an EIP-7702 authorization (walletClient.signAuthorization)

  • Calling facilitator POST /register with x402Version: 1

v2 example

v2-server shows:

  • @x402/express payment middleware protecting GET /weather

  • Passing an x402 feedback extension with:

    • feedbackEnabled: true

    • agentId: "..." (example uses "1133")

    • feedbackAuthEndpoint: "/signFeedbackAuth"

  • Implementing POST /signFeedbackAuth so the facilitator can request the agent owner’s signature

Last updated