ERC-7779 Redelegatable delegate account standard (Interoperable Delegated Accounts)

Draft · Accounts & wallets · created 2024-10-02

An interface that allows an externally owned account (EOA) delegated via EIP-7702 to safely migrate without storage conflicts when switching wallets and redelegating.

Why it is needed

After EIP-7702, an EOA is delegated to a smart account implementation and gains execution logic, but its storage remains attributed to the account. If a user switches wallets and redelegates to a different implementation, the storage slots used by the existing implementation may overlap with those used by the new implementation, and such storage conflicts can lead to unexpected behavior such as the account becoming locked or security vulnerabilities arising. Until now, there has been no standard external way to query which storage base a given wallet uses, so a new wallet had no basis for checking the existing delegation state or storage conflicts before redelegating. EOAs were originally simple mnemonic-based keypairs that guaranteed free movement between wallets, but the introduction of delegation created a risk of that free migration being constrained by storage issues.

What to implement

In depth

Identifying namespace via accountId

accountId() is a view function that returns a string containing the account version, name, wallet vendor name, and so on. The source does not standardize the namespace format itself, and gives "v0.1.2.7702Account.WalletProjectA" as an example format. When a wallet wants to show the user the redelegation process (e.g. "Wallet A to Wallet B"), it can fetch information about the existing implementation via this function.

accountStorageBases and the fixed slot

accountStorageBases() returns a bytes32[] array, and this array itself must be stored at the slot keccak(keccak('InteroperableDelegatedAccount.ERC.Storage')-1) & ~0xff. This array is append-only, and a newly delegated account must add its own storage base to this array during initialization. If the same entry already exists, it may choose not to add it again. Storage bases must be computed using keccak256() unless external storage is used.

Notation for external storage contracts

If an account uses an external storage contract, accountStorageBases() must return a value prefixed with the ERC number followed by the external storage contract's address. As an example in the source, if the storage contract address is 0xAAAA...AAAA, the returned value takes the form 0x777977797779...AAAA...AAAA (with 7779 repeated as the prefix denoting the ERC number).

Responsibility for verifying conflicting storage

If an account discovers a conflicting storage base, it may perform additional verification, either off-chain or on-chain, and decide whether to proceed with the delegation. If the conflicting storage contains suspicious values targeting the user, such as a shadow signer, the wallet may roll back the delegation.

onRedelegation's optional cleanup hook

onRedelegation() is an optional function called immediately before redelegation to a new implementation. When called, the existing account should perform wallet-specific logic, such as clearing storage variables as much as possible, so that the user is unaffected by the redelegation. It must verify that msg.sender is the account owner, which can be done via a custom verification scheme or a self-call. The source does not mandate complete initialization, stating that a "best effort" is expected.

Draft status

This proposal is currently in Draft status, not yet finalized, and its content may change or be abandoned.

Things to watch out for

Original ERC · ← ERCs