ERC-7741 Designating an operator via signature (Authorize Operator)

Draft · Signatures & auth · created 2024-06-03

A standard that lets a contract grant or revoke operator permissions using a single EIP-712 signature, without an on-chain transaction. Once the signature is provided, someone else can submit the transaction on the signer's behalf.

Why it is needed

To designate an operator to act on your behalf for asset-related requests in a contract such as a vault, the owner must send a setOperator transaction on-chain directly. This requires paying gas each time and holding the native coin needed to pay it. For a protocol that runs across multiple chains, this burden is even greater, since a separate transaction must be sent and native coin held on each chain. The cost and hassle are especially significant when operators are changed frequently or cross-chain interactions are common. In addition, if each protocol has its own way of approving operators, wallets and app developers must integrate a different approach every time. This standard defines a common way to approve operators via an EIP-712 signature, reducing gas costs, enabling meta-transactions, and allowing the same approach to be used across multiple protocols and chains.

What to implement

In depth

Applies to: the IOperator interface

This signature-based approval mechanism applies to any contract that implements the IOperator interface. This interface consists of setOperator(operator, approved) for setting operator permissions, isOperator(owner, operator) for querying permission status, and the OperatorSet event for signaling permission changes. According to the original text, EIP-6909 and EIP-7540 already implement this interface. Argument names are interchangeable; for example, EIP-6909 uses the name spender instead of operator.

Inputs and required rules for authorizeOperator

Grants or revokes an operator's permission to manage Requests on behalf of msg.sender, using an EIP-712 signature. The inputs are owner (address), operator (address), approved (bool), nonce (bytes32), deadline (uint256), and signature (bytes), and the output is success (bool). The implementation MUST do the following: revert if the deadline has passed; invalidate the signature's nonce to prevent replay; and revert if the signature is not a valid EIP-712 signature for the given inputs. If validation passes, it MUST set the operator status to the approved value, emit an OperatorSet event, and return true.

invalidateNonce and authorizations

invalidateNonce(nonce) revokes the given nonce with msg.sender as the owner. In the reference implementation, this is implemented by setting authorizations[msg.sender][nonce] to true, so that a signature using that nonce no longer works. authorizations(controller, nonce) returns a bool value used indicating whether the given nonce has already been used for controller. Both functions notably use bytes32 as the nonce type.

DOMAIN_SEPARATOR and replay attack prevention

The DOMAIN_SEPARATOR function returns, as a bytes32, a value defined according to EIP-712. This value must be unique per contract and chain in order to prevent a signature from being replayed in a different domain, and must satisfy EIP-712's requirements, but is otherwise unconstrained. In the reference implementation, the signature is verified against a digest formed by concatenating \x19\x01, DOMAIN_SEPARATOR, and the AuthorizeOperator struct hash.

ERC-165 support requirement

Contracts implementing this standard MUST implement ERC-165's supportsInterface function. It MUST return the constant value true when the interfaceID argument is 0xa9e50872. ERC-165 is a standard way to query on-chain whether a contract implements a particular interface, allowing wallets and other contracts to check in advance whether this standard is supported.

Similarity to ERC-2612 and the signature verification approach

The specification is deliberately designed to be very similar to ERC-2612. This is meant to simplify the work of newly integrating this standard. The main difference is the nonce type: it uses bytes32 instead of uint256, allowing unordered nonces. This standard also requires ERC-1271 alongside EIP-712, and the reference implementation verifies signatures using ERC-1271's isValidSignature. The reference implementation's AUTHORIZE_OPERATOR_TYPEHASH consists of the fields controller, operator, approved, nonce, and deadline. However, the original text explicitly states that the reference implementation code is incomplete example pseudocode, with no guarantee of production readiness or security.

Proposal status: Draft

This proposal is a Standards Track ERC written on June 3, 2024, and its current status is Draft. Since it is not yet a finalized standard and its content may change, the latest original text should be checked before implementing or integrating it. The authors are Jeroen Offerijns and João Martins, and it specifies EIP-712 and ERC-1271 as requirements.

Things to watch out for

Original ERC · ← ERCs