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
Anchor
contract 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 theRegistry
contract 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
Anchor
contract and can execute calls to external addresses. Ownership is verified through the associated profile ID. - Registry Contract: The
Anchor
contract relies on theRegistry
contract 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
_profileId
as a parameter and sets it as theprofileId
for the contract. - It also sets the
registry
variable by taking the sender's address as an instance of theRegistry
contract.
- Users can execute a call to a target address by calling the
execute
function. - The function requires
_target
,_value
, and_data
as parameters. - The function checks if the caller is the owner of the specified profile using the
isOwnerOfProfile
function from theRegistry
contract. - Reverts if
_target
address isaddress(0)
- It then attempts to call the
_target
address with the provided_value
and_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_FAILED
error.