The AVSGovernance contract is responsible for operator registration and deregistration. The Othentic Stack allows developers to implement their custom logics during this process.
The IAVSGovernanceLogic provides pre and post execution hooks for operator registration and deregistration on-chain.
Interface
The interface defines four functions: before and after operator registration, as well as before and after unregistration. Developers can use these functions to implement custom logic during these events.
// SPDX-License-Identifier: BUSL-1.1
pragma solidity >=0.8.20;
/**
* @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 IAvsGovernanceLogic {
function beforeOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external;
function afterOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external;
function beforeOperatorUnregistered(address _operator) external;
function afterOperatorUnregistered(address _operator) external;
}
Now, the AVS contracts are set and ready to be used ✅
Use cases
Dynamic Operator Allocation to Task Definition
Usage
Operators can be assigned dynamically to specific Task definition based on their expertise.
function afterOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external override {
_assignOperatorToTasks(_operator);
emit OperatorAssignedToTask();
}
function _assignOperatorToTasks(address _operator) internal {
// Custom logic to dynamically set operators for tasks
}
Gated Operator Registrations
AVSs may require whitelisting operators before allowing registration. This can be enforced via the beforeOperatorRegistered function.
Usage
Whitelisting: Maintain a list of approved operators.
function beforeOperatorRegistered(address _operator, uint256 _numOfShares, uint256[4] calldata _blsKey) external {
require(isWhitelisted[_operator], "Operator is not whitelisted");
}
Token-Gated Access: Require operators to hold a specific NFT or ERC-20 token.
Reputation-Based Selection: Only allow operators with a certain reputation score to register.
Post Registration Benefits
Operators that register to your AVS can be granted NFTs or whitelisted to use certain services in your AVS. These can be enabled using the afterOperatorRegistered function.
Usage
NFT Minting: Reward operators with a proof-of-registration NFT.
Exclusive Access: Enable operators to use specific AVS features.
Token Incentives: Distribute rewards for registered operators.
These functions are called inside the and functions respectively.
After deployment, you must call the function on the AvsGovernance , providing the address of the AvsGovernanceLogic contract as a parameter, as shown in the below example.
AVSs may require dynamically assigning specific operators to based on predefined conditions. This can be implemented using the beforeOperatorRegistered and afterOperatorRegistered hooks.