MPP.X402 (mpp v0.19.0)

Copy Markdown View Source

x402 v2 exact interoperability (HTTP transport, EVM EIP-3009 only).

Protocol authority is the x402 v2 specification and live facilitator traffic. refs/mppx/src/x402 is the SDK compatibility target (scheme "exact" only; refs/mppx/src/x402/Types.ts).

challenges_from_header/1 does not take a request URL and does not require resource.url to equal the response URL. mppx #908 (0.11.0) dropped that client check: query strings, redirects, proxies, and port rewriting made the two URLs differ, and the exact match turned a payable offer into a silent miss. Binding the paid resource stays on MPP.X402.Plug (:resource_mismatch when the echoed credential resource does not match).

Out of scope: MCP, x402 v1 (X-PAYMENT), non-EVM CAIP-2 families, schemes other than exact, and Permit2 client signing.

API Functions

FunctionArityDescriptionParam Kinds
chain_id1Parse eip155:<id> into a positive chain id.network: value
exact_request1Decode the Exact request object stored on a synthetic challenge.challenge: value
challenges_from_header1Parse PAYMENT-REQUIRED into synthetic challenges. No request_url argument: resource.url is not matched to the response URL, because that equality dropped payable offers when query strings, redirects, proxies, or port rewriting made the URLs differ (mppx #908). MPP.X402.Plug still binds the paid resource.header: value
synthetic?1Return true when a challenge was synthesized from a PAYMENT-REQUIRED offer.challenge: value
synthetic_id_prefix0Return the synthetic challenge-id prefix for x402 accepts.-
exact_intent0Return the MPP intent name used for synthetic x402 exact challenges.-
payment_method0Return the MPP method name used for synthetic x402 exact challenges.-
version0Return the x402 protocol version.-

Summary

Functions

Parse eip155:<id> into a positive chain id.

Parse a PAYMENT-REQUIRED header into synthetic MPP.Challenge structs.

MPP intent name used for synthetic x402 exact challenges.

Decode the Exact request object stored on a synthetic challenge.

MPP method name used for synthetic x402 exact challenges.

Return true when a challenge was synthesized from an x402 PAYMENT-REQUIRED offer.

Prefix for synthetic challenge IDs derived from PAYMENT-REQUIRED accepts.

x402 v2 protocol version.

Functions

chain_id(arg1)

@spec chain_id(String.t()) :: {:ok, pos_integer()} | {:error, atom()}

Parse eip155:<id> into a positive chain id.

challenges_from_header(header)

@spec challenges_from_header(String.t()) ::
  {:ok, [MPP.Challenge.t()]} | {:error, atom()}

Parse a PAYMENT-REQUIRED header into synthetic MPP.Challenge structs.

Unsupported accepts (non-exact, non-EVM, Permit2) are dropped. An empty remainder is {:ok, []}. There is no request_url argument: resource.url is not compared to the response URL. That equality check dropped payable offers when query strings, redirects, proxies, or port rewriting made the two URLs differ (mppx #908). MPP.X402.Plug still rejects a credential whose echoed resource does not match the server-bound URL.

exact_intent()

@spec exact_intent() :: String.t()

MPP intent name used for synthetic x402 exact challenges.

exact_request(challenge)

@spec exact_request(MPP.Challenge.t()) :: {:ok, map()} | {:error, atom()}

Decode the Exact request object stored on a synthetic challenge.

payment_method()

@spec payment_method() :: String.t()

MPP method name used for synthetic x402 exact challenges.

synthetic?(challenge)

@spec synthetic?(term()) :: boolean()

Return true when a challenge was synthesized from an x402 PAYMENT-REQUIRED offer.

synthetic_id_prefix()

@spec synthetic_id_prefix() :: String.t()

Prefix for synthetic challenge IDs derived from PAYMENT-REQUIRED accepts.

version()

@spec version() :: 2

x402 v2 protocol version.