diff --git a/ERCS/erc-7710.md b/ERCS/erc-7710.md index b4b1b5ea2a..e8084e89d7 100644 --- a/ERCS/erc-7710.md +++ b/ERCS/erc-7710.md @@ -2,21 +2,22 @@ eip: 7710 title: Smart Contract Delegation Interfaces description: Minimal interfaces to enable smart contracts to consistently delegate capabilities to other contracts or EOAs. -author: Ryan McPeck (@McOso), Dan Finlay (@DanFinlay), Rob Dawson (@rojotek) +author: Ryan McPeck (@McOso), Dan Finlay (@DanFinlay), Rob Dawson (@rojotek), Derek Chiang (@derekchiang) discussions-to: https://ethereum-magicians.org/t/towards-more-conversational-wallet-connections-a-proposal-for-the-redeemdelegation-interface/16690 status: Draft type: Standards Track category: ERC created: 2024-05-20 -requires: 1271 +requires: 1271, 7579 --- ## Abstract -This proposal defines interfaces for smart contracts to delegate capabilities to other smart contracts, -smart contract accounts, or Externally Owned Accounts (EOAs). The delegating contract MUST -implement [ERC-1271](./eip-1271.md) along with the `IDelegator` interface. This framework empowers a -delegating contract with the ability to delegate any actions it has the authority to perform, +This proposal introduces a standard way for smart contracts to delegate capabilities to other smart contracts +or Externally Owned Accounts (EOAs). The delegating contract (delegator) must implement [ERC-1271](./eip-1271.md), +and must be able to authorize a `DelegationManager` contract to call the delegator to execute the desired action. + +This framework empowers a delegating contract with the ability to delegate any actions it has the authority to perform, thereby enabling more flexible and scalable contract interactions. This standard outlines the minimal interface necessary to facilitate such delegation. @@ -70,7 +71,7 @@ Delegator which executes the specified capability on behalf of the Delegator. flowchart LR redeemer(["redeemer"]) --"redeemDelegation"--> Delegation_Manager(["Delegation Manager"]) Delegation_Manager -.->|validate delegation w/ Action| Delegation_Manager - Delegation_Manager --"executeDelegatedAction"--> Delegator(["Delegator"]) + Delegation_Manager --"execute delegated action"--> Delegator(["Delegator"]) Delegator --"executes CALL using Action"--> Target(["Target"]) classDef action stroke:#333,stroke-width:2px,stroke-dasharray: 5, 5; @@ -80,52 +81,29 @@ flowchart LR ### Interfaces -#### `ERC7710.sol` +#### `ERC7710Manager.sol` -To comply with this standard, a smart contract MUST implement this execution -interface to become a Delegator. +The Delegation Manager MUST implement the `redeemDelegation` which will be responsible for validating the delegation +being invoked, and will then call the delegator to execute the action. -The `executeDelegatedAction` function SHOULD only allow calls from an approved Delegation Manager. +The bytes `_authority` passed in as a parameter to the `redeemDelegation` function contains the authority to execute a +specific action on behalf of the delegating contract. + +The `Action` struct has two fields: `mode` and `executionCalldata`, which are defined precisely as in ERC-7579 (under the "Execution Behavior" section). Briefly, `mode` encodes the "behavior" of the execution, which could be a single call, a batch call, a delegatecall, and others. `executionCallData` encodes the data of the execution, which typically includes at least a `target`, a `value`, and a `to` address. ```solidity pragma solidity 0.8.23; + /** - * @notice Action struct is a basic Call struct. * @title Action * @notice This struct represents an action to be taken. - * @dev It only includes the functional part of a transaction, allowing it to be - * agnostic whether this was sent from a protocol-level tx or UserOperation. + * @dev `mode` and `executionCalldata` are as defined in ERC-7579. */ struct Action { - address to; - uint256 value; - bytes data; + bytes32 mode; + bytes executionCalldata; } -/** - * @title ERC7710 - * @notice Interface for a Delegator that exposes the minimal functionality required. - */ -interface ERC7710 is IERC1271 { - /** - * @notice executes a CALL using the data provided in the action - * @dev SHOULD enforce calls coming from an approved DelegationManager address - * @param _action the onchain action to perform - */ - function executeDelegatedAction(Action calldata _action) external; -} -``` - -#### `ERC7710Manager.sol` - -The Delegation Manager MUST implement the `redeemDelegation` which will be responsible for validating the delegation -being invoked, and will then call the `executeDelegatedAction` on the delegating contract. - -The bytes `_data` passed in as a parameter to the `redeemDelegation` function contains the authority to execute a -specific action on behalf of the delegating contract. - -```solidity -pragma solidity 0.8.23; /** * @title ERC7710Manager * @notice Interface for Delegation Manager that exposes the redeemDelegation function. @@ -133,11 +111,11 @@ pragma solidity 0.8.23; interface ERC7710Manager { /** * @notice This method validates the provided data and executes the action if the caller has authority to do so. - * @dev the structure of the _data bytes is determined by the specific Delegation Manager implementation - * @param _data the data used to validate the authority given to execute the action. + * @dev the structure of the _authority bytes is determined by the specific Delegation Manager implementation + * @param _authority the data used to validate the authority given to execute the action. * @param _action the action to be executed */ - function redeemDelegation(bytes calldata _data, Action calldata _action) external; + function redeemDelegation(bytes calldata _authority, Action calldata _action) external; } ``` @@ -165,6 +143,26 @@ enhancing the overall user experience. This ERC represents a step towards a more interconnected and flexible Ethereum ecosystem, where smart contracts can more effectively collaborate and adapt to users' needs. +### Execution Interface + +A previous iteration of this spec defined `Action` as a simple `(target, value, data)` tuple, and defined a specific +execution interface on the delegator that is `executeDelegatedAction(Action _action)` which the Delegation Manager is +supposed to call. + +That approach had a few downsides: + +- Existing smart accounts won't be compatible with this spec (unless they happen to implement the execution interface). +- The execution behavior is limited to a single call, since `Action` could only encode a single call. It made complex + execution behaviors such as batching, delegatecall, and CREATE2 impossible. + +To solve the first issue, we decided to remove the requirement for the delegator to implement any specific interface. +Rather, we rely on the Delegation Manager to correctly call the delegator, and we rely on the fact that a delegator would +only create `_authority` for a Delegation Manager that knows how to correctly call it. + +To solve the second issue, we decied to adopt the execution interface from ERC-7579, which had to solve a similar problem +within the context of modular smart accounts: defining a standardized execution interface that can support many types of +executions. + ## Security Considerations The introduction of customizable authorization terms requires careful consideration of how authorization data is