Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.x402r.org/llms.txt

Use this file to discover all available pages before exploring further.

Overview

AuthorizationTimeRecorderHook stores block.timestamp at the moment the operator authorizes a payment. Time-based conditions like EscrowPeriod read this timestamp to gate later actions.
EscrowPeriod extends AuthorizationTimeRecorderHook and adds an ICondition implementation. For escrow enforcement, use EscrowPeriod directly instead of deploying AuthorizationTimeRecorderHook on its own.

State

mapping(bytes32 paymentInfoHash => uint256 authorizedAt) public authorizationTimes;

Methods

// Called after authorize()
function run(
    AuthCaptureEscrow.PaymentInfo calldata paymentInfo,
    uint256 /* amount */,
    address /* caller */,
    bytes calldata /* data */
) external {
    bytes32 hash = _verifyAndHash(paymentInfo);
    authorizationTimes[hash] = block.timestamp;
}

// View function
function getAuthorizationTime(
    AuthCaptureEscrow.PaymentInfo calldata paymentInfo
) external view returns (uint256) {
    return authorizationTimes[escrow.getHash(paymentInfo)];
}
amount, caller, and data are unused; they exist to satisfy IHook.run.

When to Use

Use AuthorizationTimeRecorderHook directly only if you need authorization timestamps without escrow period enforcement. For most use cases, EscrowPeriod is the better choice since it includes this hook plus time-lock condition logic.

Gas

Cost: ~20k gas per run() call (one SSTORE for the timestamp).

Next Steps

EscrowPeriod

Combined hook + condition for escrow enforcement.

PaymentIndexRecorderHook

Index payments for on-chain queries.