ERC-7598 Contract Signature Transfer Extension (Use contract signature for signed transfer)

Draft · Tokens · created 2024-01-15

An extension standard that adds ERC-1271 contract signature verification so smart contract wallets can also use ERC-3009's signature-based transfer (Transfer With Authorization).

Why it is needed

ERC-3009 is a standard that lets a third party execute a transfer on behalf of a token owner using a pre-signed authorization, but its signature scheme is tied to a specific digital signature algorithm, ECDSA. ECDSA signatures can only be created by standard accounts (EOAs) that hold a private key directly, so smart contract wallets, which operate via code rather than a private key, cannot produce signatures in this format. As contract wallets become more common in the ecosystem, relying on the existing standard alone leaves a gap where these wallet users cannot use the signature-based transfer feature. This proposal aims to combine ERC-1271 verification, which lets a contract determine signature validity itself, with ERC-3009, so that transfers can be authorized securely in the same way regardless of wallet type.

In depth

Elements that must be preserved from ERC-3009

Even with this extension implemented, the core elements of ERC-3009 must remain unchanged. The AuthorizationUsed event that signals authorization use, the TRANSFER_WITH_AUTHORIZATION_TYPEHASH and RECEIVE_WITH_AUTHORIZATION_TYPEHASH constants, and the view function authorizationState(address authorizer, bytes32 nonce), which checks whether a given authorizer and nonce have been used, all remain required. In other words, this proposal does not replace ERC-3009, it extends the signature input format.

New functions that consolidate signature parameters into bytes

The required additions transferWithAuthorization and receiveWithAuthorization take a single bytes memory signature parameter instead of the existing ERC-3009's three parameters v, r, s. This byte string may be an ECDSA signature produced by an EOA, or a custom-format signature produced by a contract wallet. from is the paying authorizer, to is the recipient, validAfter and validBefore define the validity window in Unix time, and nonce is a unique value that prevents reuse. receiveWithAuthorization additionally checks that the caller matches the recipient address, preventing front-running attacks.

The optional authorization cancellation feature

The AuthorizationCanceled event and CANCEL_AUTHORIZATION_TYPEHASH constant defined in ERC-3009 are optional in this extension. If supported, the function cancelAuthorization(address authorizer, bytes32 nonce, bytes memory signature) can cancel an authorization that has not yet been used, and the signature for the cancellation request is likewise an unstructured bytes format that both EOAs and contract wallets can produce.

Why unstructured bytes were chosen over v, r, s

The existing v, r, s verification method presumes an ECDSA signature structure. Switching to an unstructured bytes input lets contract developers verify both EOA signatures and contract wallet signatures through a single unified interface. According to the stated design intent in the source text, this allows different signature methods and algorithms suited to each wallet type to be used, giving contract wallets and advanced wallets room to develop their own signature verification procedures.

Compatibility with existing ERC-3009 implementations

This proposal is fully backward compatible with existing ERC-3009 implementations. Existing contracts that rely on the v, r, s method continue to work unchanged. The source text provides example code showing that if both methods need to be supported together, the existing function that takes v, r, s can internally build the bytes via abi.encodePacked(r, s, v) and call the new function, reducing duplicate implementation.

The verification procedure shown in the reference implementation

The reference implementation first checks that the current time is after validAfter and before validBefore, and that the given nonce has not yet been used. It then builds a digest by combining the domain separator and type hash in the EIP-712 manner, and checks both ECDSA signatures and ERC-1271 signatures using a tool such as OpenZeppelin's SignatureChecker.isValidSignatureNow. Once verification passes, the nonce is marked as used, an AuthorizationUsed event is emitted, and the transfer is executed. EOA signatures must be concatenated in the order r, s, v.

Proposal status

This document is a proposal in Draft status, created on January 15, 2024. Since the content may change going forward, developers who intend to implement it should check the latest source text.

Things to watch out for

Original ERC · ← ERCs