Install

Works with Drupal: ^11.1 || ^12

Using Composer to manage Drupal site dependencies

Alternative installation files

Download tar.gz 74.54 KB
MD5: 2908aef8f1b805391ce65bf9829b03fe
SHA-1: 16a634999c1bd7f96ecd313030d25fe9f41db53d
SHA-256: 87d040778495453949c67ce8bd628f15e8f6704bbcf775f1bf623f537b077441
Download zip 107.67 KB
MD5: e22eb10e9f4e3ebaf5190617a7e5165b
SHA-1: 21021b0cd9ca74a71a46e9ee11107f248f3fd553
SHA-256: 3aed0a00a18a1d4bbe1b2ba29a6da52c2733cc35a0a095999beaece227eb7ef9

Release notes

First beta of x402 Pay: Drupal charges for content and API calls in USDC on Arc over HTTP 402, following the x402 protocol. No accounts, no checkout: an agent (or a person's wallet) gets a 402 with the price, signs a payment, and gets the response.

What's in it

  • The payment gate (x402_pay.gate): any controller can charge per request. Verify, run the handler, and settle only when the response is a 2xx, so a failed call costs the buyer nothing. A payment log keeps route, amount, payer and transaction hash; a Server-Timing header says where the time went.
  • The x402_price field: add it to any fieldable entity and its content is for sale. Each field sells one view mode at a price; several fields sell several (full text, summary). Per entity price overrides, a price per translation, and a switch to sell for free.
  • Agents pay, browsers browse: on the entity's own URL, requests from agents (a payment header, a non-HTML Accept, or a known AI user agent) get the 402 while people still see the page. Every product also lives at /x402/{entity_type}/{id}/{view_mode}, announced with Link headers. Buyers receive the view mode's fields as Markdown.
  • Discovery: /x402/discovery lists everything for sale in the shape of Circle's Discovery API, so marketplace clients read it unchanged. For people, a Views filter (Charge for this) and a price formatter.
  • Events: PriceEvent before every sale (change the price, make it free, deny it, choose the seller wallet, set the timeout) and DeliveryEvent to answer with something else than Markdown, e.g. a paid API call.
  • Three ways to settle, per network, at Configuration → Web services → x402 Pay:
    • Circle's facilitator, keyless trial (each sale signed by the seller's key).
    • Circle's facilitator with an API key: sellers can be plain addresses, no key on the site.
    • The site's own facilitator: Drupal sends the buyer's signed transferWithAuthorization on chain from a gas wallet that pays only the gas. No third party.
  • Sweeping: seller keys kept on the site can be emptied to a cold wallet on cron or with drush x402:sweep [--dry-run], so a compromised site loses at most what arrived since the last sweep.
  • Networks: Arc mainnet (eip155:5042) and Arc testnet (eip155:5042002).

Security

  • Keys only through the Key module, from environment variables; never in exportable configuration.
  • EIP-712 hashing, secp256k1 signing and EIP-1559 transactions in PHP, equal byte for byte to viem (test vectors included).
  • The page cache never hands a paid response to an unpaid request (covered by a functional test).
  • Permissions: Set x402 prices, Access x402 content free, Administer x402 Pay.

Known limits

  • The x402 exact scheme on Arc only; other EVM chains and Solana are planned.
  • The own facilitator accepts plain wallet (EOA) signatures; smart-contract wallets (ERC-1271) are planned.
  • Coming: a Drupal Commerce gateway (x402_pay_commerce) and ECA integration (x402_pay_eca).
  • Beta: APIs and configuration may change before 1.0.0.

Requires Drupal ^11.1 || ^12, PHP 8.3+ with ext-gmp, and the Key module.

Created by: leofishman
Created on: 13 Oct 2026 at 16:38 UTC
Last updated: 13 Oct 2026 at 16:39 UTC
New features

Other releases