MPP.Methods.EVM.Permit2 (mpp v0.18.0)

Copy Markdown View Source

EVM Permit2 credentials with challenge-bound witnesses and ordered splits.

Enable with "permit2" => true and a server "private_key" in method_config. sign/5 takes the server's transaction-sending address as spender; this must be agreed with the client because draft-evm-charge-00 does not define spender discovery. The payer must already approve the Permit2 contract for the token.

The draft's exact witness suffix contains a space after the comma. Preserve it in the Permit2 root type hash; the nested PaymentWitness struct uses the canonical EIP-712 encoding. The canonical contract's batch entry point is an overload of permitWitnessTransferFrom, not permitBatchWitnessTransferFrom.

Summary

Functions

Encode the canonical single or batch overload, retaining the draft witness suffix.

Compute the exact draft witness / canonical Permit2 EIP-712 digest.

Return whether this charge has an explicitly configured Permit2 settler.

Verify, submit, and confirm every ordered transfer in a Permit2 credential.

Sign a credential; nonce and deadline are decimal uint256 strings.

Validate the charge binding and recover the payer before any RPC or submission.

Functions

calldata(payload, owner)

@spec calldata(map(), String.t()) :: {:ok, String.t()} | {:error, term()}

Encode the canonical single or batch overload, retaining the draft witness suffix.

digest(payload, charge, spender)

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

Compute the exact draft witness / canonical Permit2 EIP-712 digest.

offered?(charge)

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

Return whether this charge has an explicitly configured Permit2 settler.

settle(payload, charge)

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

Verify, submit, and confirm every ordered transfer in a Permit2 credential.

sign(charge, private_key, spender, nonce, deadline)

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

Sign a credential; nonce and deadline are decimal uint256 strings.

verify(payload, charge)

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

Validate the charge binding and recover the payer before any RPC or submission.