Skip to main content

Overview

AuthorizationTimeRecorder stores the block.timestamp when a payment is authorized. This timestamp is used by time-based conditions like EscrowPeriod.
EscrowPeriod extends AuthorizationTimeRecorder and adds ICondition implementation. For escrow enforcement, use EscrowPeriod directly instead of deploying AuthorizationTimeRecorder separately.

State

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

Methods

// Called after authorize()
function record(
    AuthCaptureEscrow.PaymentInfo calldata paymentInfo,
    uint256 amount,
    address caller
) external {
    bytes32 hash = escrow.getHash(paymentInfo);
    authorizationTimes[hash] = block.timestamp;
}

// View function
function getAuthorizationTime(
    AuthCaptureEscrow.PaymentInfo calldata paymentInfo
) external view returns (uint256) {
    return authorizationTimes[escrow.getHash(paymentInfo)];
}

When to Use

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

Gas

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

Next Steps