Payment Request

Overview

AttestationCenter contract is responsible for operator payment requests. The IBeforePaymentsLogic interface offers a pre-execution hook for payment requests on-chain.

Interface

The interface defines a function beforePaymentRequest for handling operator payment requests. AVS developers can implement custom logic for this event.

// 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;

}

This hook can be called inside the requestPayment function in AttestationCenter .

    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);    
    }

Deployment & Setup

After implementation, you can deploy the contract on the same L2 network as the AttestationCenter.

Make sure to deploy the Othentic contracts before deploying the AVS Logic.

After deployment, you must call the setBeforePaymentsLogic function in AttestationCenter and provide the address of the BeforePaymentRequest contract as the parameter. Note that only the AVS Governance Multisig is authorized to call this function.

Now, the AVS contracts are set and ready to be used.

Last updated