Task Logic

Learn more about Task Logic Hook

Prerequisites

  • AVS contracts

  • Access to AVS governance multisig

1

Set Up the Contract

Create a contract called AVSLogic , use IAVSLogic interface to override beforeTaskSubmission and afterTaskSubmission hook functions for custom logic.

contract AvsLogic is IAvsLogic {

}
2

Deploy the contract

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

3

Register AVSLogic with AttestationCenter

After deployment, call the setAvsLogic function on the AttestationCenter and provide the address of the AvsLogic contract as the parameter, as shown in the script below.

Script to execute setAvsLogic function
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

/*______     __      __                              __      __ 
 /      \   /  |    /  |                            /  |    /  |
/$$$$$$  | _$$ |_   $$ |____    ______   _______   _$$ |_   $$/   _______ 
$$ |  $$ |/ $$   |  $$      \  /      \ /       \ / $$   |  /  | /       |
$$ |  $$ |$$$$$$/   $$$$$$$  |/$$$$$$  |$$$$$$$  |$$$$$$/   $$ |/$$$$$$$/ 
$$ |  $$ |  $$ | __ $$ |  $$ |$$    $$ |$$ |  $$ |  $$ | __ $$ |$$ |
$$ \__$$ |  $$ |/  |$$ |  $$ |$$$$$$$$/ $$ |  $$ |  $$ |/  |$$ |$$ \_____ 
$$    $$/   $$  $$/ $$ |  $$ |$$       |$$ |  $$ |  $$  $$/ $$ |$$       |
 $$$$$$/     $$$$/  $$/   $$/  $$$$$$$/ $$/   $$/    $$$$/  $$/  $$$$$$$/
*/
/**
 * @author Othentic Labs LTD.
 * @notice Terms of Service: https://www.othentic.xyz/terms-of-service
 */

import {Script, console} from "forge-std/Script.sol";
import "../src/IAttestationCenter.sol";
import "../src/AvsLogic.sol";

// forge script AvsLogicScript --rpc-url $L2_RPC --private-key $PRIVATE_KEY
// --broadcast -vvvv --verify --etherscan-api-key $L2_ETHERSCAN_API_KEY --chain
// $L2_CHAIN --verifier-url $L2_VERIFIER_URL --sig="run(address)" $ATTESTATION_CENTER_ADDRESS
contract AvsLogicScript is Script {
    function setUp() public {}

    function run(address attestationCenter) public {
        vm.broadcast();
        AvsLogic avsLogic = new AvsLogic(attestationCenter);
        IAttestationCenter(attestationCenter).setAvsLogic(address(avsLogic));
    }
}

Note that only the AVS Governance Multisig is authorized to call this function.

4

Verify the Hook contract

Call the avsLogic function on the Attestation center contract to confirm that the AVS logic hook contract has been correctly registered.


Last updated