X402.AuthCapture.Receipt (X402 v0.9.6)

Copy Markdown View Source

Strict auth-capture receipt identity and escrow-event checks.

Expected events come from the execution layer's full verification result, not a request-provided assertion. Successful receipts must contain exactly one matching event from the configured escrow, with canonical ABI data and matching transaction/block provenance. Reverted receipts must have no logs.

This pure check does not establish chain identity, canonical inclusion, or finality. The execution layer must check those against its trusted RPC before recording a final journal outcome. Contract addresses are deployment configuration, not independent runtime-code authenticity proofs.

Summary

Functions

Checks receipt identity, status and event data, returning unfinalized inclusion.

Builds the exact escrow event for a fully verified operation.

Types

event()

@type event() :: %{address: String.t(), topics: [String.t()], data: String.t()}

identity()

@type identity() :: %{hash: String.t(), from: String.t(), to: String.t()}

inclusion()

@type inclusion() :: %{
  outcome: :confirmed | :reverted,
  block_hash: String.t(),
  block_number: non_neg_integer(),
  transaction_index: non_neg_integer()
}

Functions

check(receipt, identity, event)

(since 0.9.0)
@spec check(term(), identity(), event()) :: {:ok, inclusion()} | {:error, atom()}

Checks receipt identity, status and event data, returning unfinalized inclusion.

identity must come from the frozen transaction. A successful result still needs canonical-block and confirmation-depth checks by the execution layer.

Examples

iex> X402.AuthCapture.Receipt.check(nil, %{}, %{})
{:error, :invalid_receipt}

expected_event(verification, leg \\ :primary)

(since 0.9.0)
@spec expected_event(
  X402.Verify.AuthCaptureEVM.verification(),
  :primary | :void_remainder
) ::
  {:ok, event()} | {:error, term()}

Builds the exact escrow event for a fully verified operation.

:primary selects the original operation. :void_remainder selects the separately submitted void leg after a partial capture and uses the remaining capturable balance, not the captured amount.

Examples

iex> X402.AuthCapture.Receipt.expected_event(%{})
{:error, :invalid_verification}