The Anchor contract serves as a crucial utility within the Allo ecosystem, facilitating the execution of calls to target addresses. Anchors are associated with profiles and are accessible exclusively to the profile owner. This contract ensures secure and authorized interaction with external addresses, enhancing the capabilities of profiles and enabling controlled execution of operations. The contract leverages the Registry contract for ownership verification and access control.
- License: The
Anchorcontract is licensed under the AGPL-3.0-only license, promoting the use of open-source software. - Solidity Version: Developed using Solidity version 0.8.19, harnessing the latest advancements in Ethereum smart contract technology.
registry(Public Immutable): A reference to theRegistrycontract instance, enabling access to profile ownership information and access control.profileId(Public Immutable): The profile ID associated with the anchor, used to verify the caller's ownership.
UNAUTHORIZED(): An error triggered when an unauthorized caller attempts to execute a function reserved for the profile owner.CALL_FAILED(): An error triggered when a call to a target address fails or is 0.
The constructor initializes the registry variable with a reference to the Registry contract and assigns the provided profile ID to the profileId variable.
execute: Execute a call to a target address, sending a specified amount of native tokens and data. Only the profile owner can initiate this operation.
- Profile Owner: The profile owner has exclusive access to the
Anchorcontract and can execute calls to external addresses. Ownership is verified through the associated profile ID. - Registry Contract: The
Anchorcontract relies on theRegistrycontract to validate the profile owner's authorization before executing operations.
In summary, the Anchor smart contract offers a secure and controlled mechanism for profile owners to interact with external addresses. By utilizing the Registry contract for authorization, the Anchor contract ensures that only authorized users can execute calls. Through its well-structured storage variables, constructor, and external function, the Anchor contract contributes to enhancing the capabilities of profiles within the Allo ecosystem.
- The contract's constructor takes a
_profileIdas a parameter and sets it as theprofileIdfor the contract. - It also sets the
registryvariable by taking the sender's address as an instance of theRegistrycontract.
- Users can execute a call to a target address by calling the
executefunction. - The function requires
_target,_value, and_dataas parameters. - The function checks if the caller is the owner of the specified profile using the
isOwnerOfProfilefunction from theRegistrycontract. - Reverts if
_targetaddress isaddress(0) - It then attempts to call the
_targetaddress with the provided_valueand_data. - If the call is successful, the function returns the data returned by the target call.
- If the call fails, the function reverts with a
CALL_FAILEDerror.