Before Payment Logic

Overview

AttestationCenter contract is responsible for operator payment requests. The Othentic Stack allows developers to implement their custom logic during this process.

IBeforePaymentsLogic provides a pre-execution hook for payment requests on-chain.

Interface

// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.25;

/*______     __      __                              __      __ 
 /      \   /  |    /  |                            /  |    /  |
/$$$$$$  | _$$ |_   $$ |____    ______   _______   _$$ |_   $$/   _______ 
$$ |  $$ |/ $$   |  $$      \  /      \ /       \ / $$   |  /  | /       |
$$ |  $$ |$$$$$$/   $$$$$$$  |/$$$$$$  |$$$$$$$  |$$$$$$/   $$ |/$$$$$$$/ 
$$ |  $$ |  $$ | __ $$ |  $$ |$$    $$ |$$ |  $$ |  $$ | __ $$ |$$ |
$$ \__$$ |  $$ |/  |$$ |  $$ |$$$$$$$$/ $$ |  $$ |  $$ |/  |$$ |$$ \_____ 
$$    $$/   $$  $$/ $$ |  $$ |$$       |$$ |  $$ |  $$  $$/ $$ |$$       |
 $$$$$$/     $$$$/  $$/   $$/  $$$$$$$/ $$/   $$/    $$$$/  $$/  $$$$$$$/
*/
import { IAttestationCenter } from "./IAttestationCenter.sol";
/**
 * @author Othentic Labs LTD.
 * @notice Terms of Service: https://www.othentic.xyz/terms-of-service
 * @notice Depending on the application, it may be necessary to add reentrancy gaurds to hooks
 */
interface IBeforePaymentsLogic {

    function beforePaymentRequest(uint256 _operatorId, IAttestationCenter.PaymentDetails calldata _paymentDetails, uint32 _taskNumber) external;

}

The interface declares one function, before operator payment request. AVS developers can implement custom logic during this event.

This hook can be called inside the requestPayment function.

    function requestPayment(uint256 _operatorId) external whenFlowNotPaused(PauserRolesLibrary.PAYMENT_REQUEST_FLOW) nonReentrant {
        AttestationCenterStorageData storage _sd = _getStorage();
        PaymentDetails storage _details = _sd.operators[_operatorId];
        uint32 _taskNumber = _sd.taskNumber;
        IBeforePaymentsLogic _beforePaymentsLogic = _sd.beforePaymentsLogic;
        if (address(_beforePaymentsLogic) != address(0)) {
            _beforePaymentsLogic.beforePaymentRequest(_operatorId, _details, _taskNumber);
        }
        if (_details.operator != msg.sender) revert InvalidOperatorId();
        _commitPayment(_details, _taskNumber);
        uint256 _feeToClaim = _details.feeToClaim;
        if(_sd.isRewardsOnL2) {
            _withdrawL2Rewards(_sd, _details, _taskNumber, _sd.vault);
        } else {
            _triggerL1PaymentRequest(_sd, msg.sender, _feeToClaim);
        }
        emit PaymentRequested(msg.sender, _taskNumber, _feeToClaim);    
    }

Last updated