Skip to main content

prepare_transfer_with_authorization

Function prepare_transfer_with_authorization 

Source
pub fn prepare_transfer_with_authorization(
    domain: Eip3009Domain,
    authorization: TransferWithAuthorizationInput,
    binding: &ApprovalBinding,
    now_unix_seconds: u64,
    nonce_store: &dyn Eip3009NonceStore,
) -> Result<PreparedTransferWithAuthorization, SettlementError>
Expand description

Prepare an EIP-3009 transferWithAuthorization digest, enforcing the money-safety invariants before any signature is broadcast:

  1. Single-use nonce. nonce_store.record_if_fresh(from, nonce) is consulted first; a previously-seen (from, nonce) pair fails closed with SettlementError::InvalidBinding, rejecting replays.
  2. Time window vs. now. The authorization is accepted only when valid_before > now_unix_seconds > valid_after; an expired or not-yet-valid window fails closed.
  3. Authorization must not outlive the approval. The EIP-3009 valid_before must not exceed binding.approval_expires_at. A signed transfer stays broadcastable on-chain until valid_before, so an authorization whose window outlasts the governing approval is rejected to keep the off-chain spend bounded by the approval window.
  4. Approval binding. The domain chain_id, authorization to (payee), value (amount), and token identity (the domain verifying_contract against the REQUIRED binding.token_contract) are asserted against binding; any mismatch (or an absent token contract) fails closed. The caller resolves binding from the verified governing approval from governed approval validation.

All checks fail closed. The nonce is recorded only after the time-window, expiry, and binding checks pass, so a rejected authorization does not burn its nonce.