# Task Logic

{% hint style="info" %}
Learn more about [Task Logic Hook ](https://docs.othentic.xyz/main/learn/advanced-concepts/hooks/task-logic)
{% endhint %}

### Prerequisites

* AVS contracts
* Access to AVS governance multisig

{% stepper %}
{% step %}

### Set Up the Contract <a href="#set-up-the-contract" id="set-up-the-contract"></a>

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

```solidity
contract AvsLogic is IAvsLogic {

}
```

{% endstep %}

{% step %}

### Deploy the contract&#x20;

After implementation, deploy the contract on the same L2 network as the `AttestationCenter`.
{% endstep %}

{% step %}

### Register AVSLogic with AttestationCenter

After deployment, call the [setAvsLogic](https://github.com/Othentic-Labs/core-contracts/blob/main/src/NetworkManagement/L2/AttestationCenter.sol#L226) function on the `AttestationCenter` and provide the address of the AvsLogic contract as the parameter, as shown in the script below.

<details>

<summary>Script to execute setAvsLogic function</summary>

```solidity
// 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));
    }
}
```

</details>

Note that only the **AVS Governance Multisig** is authorized to call this function.
{% endstep %}

{% step %}

### 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.
{% endstep %}
{% endstepper %}

***
