MPP.Methods.EVM.Authorization (mpp v0.16.0)

Copy Markdown View Source

EIP-3009 transferWithAuthorization credential for Circle USDC/EURC.

The client signs an off-chain EIP-712 TransferWithAuthorization message. The server submits it to the token contract and pays gas. The EIP-3009 nonce is the Payment-auth challengeHash:

keccak256(challenge.id <> challenge.realm)

matching draft-evm-charge-00.md § Authorization Payload and refs/mppx/src/evm/Types.ts challengeHash. Circle FiatTokenV2 enforces nonce uniqueness on-chain (authorizationState).

Summary

Functions

Compute the EIP-3009 nonce: keccak256(challenge.id <> challenge.realm).

Return true when this charge can advertise and settle type=authorization.

Parse and validate a type=authorization credential payload.

Validate, recover, and settle an EIP-3009 authorization; return the tx hash.

Validate optional "authorization" method_config (name + version).

Types

parsed()

@type parsed() :: %{
  from: String.t(),
  to: String.t(),
  value: String.t(),
  valid_after: non_neg_integer(),
  valid_before: non_neg_integer(),
  nonce: String.t(),
  signature: String.t()
}

Functions

challenge_hash(id, realm)

@spec challenge_hash(String.t(), String.t()) :: String.t()

Compute the EIP-3009 nonce: keccak256(challenge.id <> challenge.realm).

offered?(charge)

@spec offered?(MPP.Intents.Charge.t()) :: boolean()

Return true when this charge can advertise and settle type=authorization.

parse_payload(payload)

@spec parse_payload(map()) :: {:ok, parsed()} | {:error, MPP.Errors.t()}

Parse and validate a type=authorization credential payload.

settle(payload, charge)

@spec settle(map(), MPP.Intents.Charge.t()) ::
  {:ok, String.t()} | {:error, MPP.Errors.t()}

Validate, recover, and settle an EIP-3009 authorization; return the tx hash.

validate_config!(other)

@spec validate_config!(term()) :: :ok

Validate optional "authorization" method_config (name + version).