ERC-6981 Reserved ownership account (Reserved Ownership Accounts)

Draft · Accounts & wallets · created 2023-04-25

A registry standard in which an external service reserves a predetermined Ethereum address for each user in advance, allowing the user to later deploy a smart contract wallet to that address whenever they want and take ownership of it.

Why it is needed

When a web service holds on-chain assets on behalf of users, it typically uses a custodial wallet managed by the service. This involves using an externally owned account (EOA), a pre-deployed smart contract wallet, or an omnibus contract that pools the assets of multiple users, while storing private keys or asset ownership information in an ordinary database. This approach raises security concerns and has the problem that the service effectively controls the user's assets. There is also the burden that a user must first transact directly with the blockchain in order to obtain their own address. This standard assigns users an address that is precomputed from a signed message and a unique salt, so that they can first have an address to receive assets without any on-chain transaction, and control is handed over to the user directly at a later time.

What to implement

In depth

System composition: account registry and account instances

The system consists of two parts. The Account Registry provides a deterministic address based on a service user's identifying salt, and lets the end user claim the account after signature verification. The Account Instance is created through the registry and must be able to receive assets sent to its address even before deployment. The service MUST maintain the relationship between a user's identity information and their salt, and SHOULD provide a signed message for the salt once the user's identity is verified. The signature is generated using the signing address known to the registry.

createAccount: ERC-1167 proxy deployment

createAccount deploys an account instance for the given salt. The new instance MUST be deployed as an ERC-1167 proxy pointing to the account implementation, and the initial owner SHOULD be set to the registry itself. The implementation address MUST be immutable since it is used in deterministic address computation. On successful deployment it SHOULD emit an AccountCreated event. Binding the registry and the implementation together keeps the salt-to-address mapping consistently valid within the same registry.

claimAccount: signature verification and ownership transfer

claimAccount is the function for claiming ownership of an account for a salt. If the account doesn't exist it MUST be created first, and it SHOULD verify the message and signature against owner, salt, and expiration to confirm msg.sender has claiming authority. Verification uses ECDSA for an EOA signer or ERC-1271 for a contract signer. It SHOULD also check that block.timestamp < expiration or that expiration == 0. On successful signature verification, the registry MUST fully relinquish control over the account, call the account's setOwner to assign ownership to the initial owner, and SHOULD emit an AccountClaimed event.

isValidSignature: composite hash verification for unclaimed accounts

The registry's isValidSignature is an alternative signature verification function used by accounts that have not yet been claimed. A valid signature is produced when the registry signer signs a composite hash combining the original message hash and the account address, for example keccak256(abi.encodePacked(originalHash, accountAddress)). The function MUST reconstruct the composite hash using the received hash as originalHash and msg.sender (the unclaimed account instance) as accountAddress, and MUST verify the signature against that hash and the registry signer.

The three signature states of an account instance

An account instance MUST implement ERC-1271's isValidSignature, and the signing method differs depending on its state. First, if deployed and claimed, the owner signs and the account verifies against the current owner. Second, if deployed but unclaimed, the registry signer signs the composite hash and the account delegates verification to the registry's isValidSignature. Third, if not yet deployed, the same composite hash signature is wrapped in ERC-6492 format. The verifying side also follows the ERC-6492 verification procedure. The account determines claim status by checking whether the owner is the registry.

Design rationale: per-service registries and separated operations

Rather than having one universal registry, letting each service own its own registry allows each service to implement its own authority controls and deployment approval scheme. A reference implementation provides a registry factory, including an immutable account implementation, ECDSA and ERC-1271 verification, and the ability to replace the signing address. The account implementation itself can be designed to be upgradeable, so users are not permanently locked into the initial implementation. createAccount and claimAccount are separated so that a service can give a user a valid ERC-6492 signature even before the account is deployed.

Proposal status: Draft

This proposal was created on April 25, 2023 and is currently in Draft status. It has not been finalized and its content may change. It assumes ERC-1167, ERC-1271, and ERC-6492.

Things to watch out for

Original ERC · ← ERCs