Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-7598 extends ERC-3009 by introducing support for ERC-1271 contract signature validation in signed token transfers.

This article translates, summarizes, and expands on the following proposal.

More EIP explainers:

Overview

ERC-7598 proposes extending ERC-3009 to support authorizations issued by contract wallets.

Unlike a conventional approve followed by transferFrom workflow, ERC-3009 allows a signed authorization to directly authorize a particular token transfer without first establishing an allowance.

For ERC-3009, see the following article.

ERC-3009: Understanding secure meta-transactions

Motivation

ERC-3009 enables another account to submit a token transfer authorized through an ECDSA signature.

Its traditional signature parameters are designed around externally owned accounts. As contract wallets become more common, applications also need to validate authorizations according to the signing policies of those wallets.

ERC-7598 introduces support for ERC-1271, allowing token contracts to validate authorizations issued by smart contract accounts and improving interoperability with different wallet architectures.

For ERC-1271, see the following article.

ERC-1271: Verifying signatures through smart contracts

Specification

The following ERC-3009 elements remain required:

  • The AuthorizationUsed event.
  • The TRANSFER_WITH_AUTHORIZATION_TYPEHASH and RECEIVE_WITH_AUTHORIZATION_TYPEHASH constants.
  • The authorizationState(address authorizer, bytes32 nonce) function.

The proposal adds the following interface.

js
/**
 * @notice Execute a transfer with a signed authorization
 * @param from          Payer's address (Authorizer)
 * @param to            Payee's address
 * @param value         Amount to be transferred
 * @param validAfter    The time after which this is valid (unix time)
 * @param validBefore   The time before which this is valid (unix time)
 * @param nonce         Unique nonce
 * @param signature     Unstructured bytes signature signed by an EOA wallet or a contract wallet
 */
function transferWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    bytes memory signature
) external;

/**
 * @notice Receive a transfer with a signed authorization from the payer
 * @dev This has an additional check to ensure that the payee's address matches
 * the caller of this function to prevent front-running attacks. (See security
 * considerations)
 * @param from          Payer's address (Authorizer)
 * @param to            Payee's address
 * @param value         Amount to be transferred
 * @param validAfter    The time after which this is valid (unix time)
 * @param validBefore   The time before which this is valid (unix time)
 * @param nonce         Unique nonce
 * @param signature     Unstructured bytes signature signed by an EOA wallet or a contract wallet
 */
function receiveWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    bytes memory signature
) external;

transferWithAuthorization

Executes a token transfer using a signed authorization.

  • from
    • The payer and authorizer.
  • to
    • The recipient.
  • value
    • The amount of tokens to transfer.
  • validAfter
    • The Unix timestamp after which the authorization becomes valid.
  • validBefore
    • The Unix timestamp before which the authorization must be used.
  • nonce
    • A unique authorization identifier used to prevent reuse.
  • signature
    • A byte sequence containing an EOA signature or authorization data recognized by a contract wallet.

An unstructured bytes parameter does not prescribe a particular internal signature format at the ABI level. The verifier must still interpret the bytes according to its supported signature scheme.

Background

Traditional ECDSA interfaces often accept three separate parameters: v, r, and s.

Benefits of a bytes parameter
  • Flexibility
    • Different signature schemes and wallet-specific authorization formats can be supported through a common ABI.
  • Simpler interfaces
    • Signature data can be passed as one argument rather than several fixed ECDSA components.
Examples
Traditional signature parameters
js
function transferWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    uint8 v,
    bytes32 r,
    bytes32 s
) external {
    // 署名検証ロジック
}
Unstructured bytes parameter
js
function transferWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    bytes memory signature
) external {
    // 署名検証ロジック
}

A conventional ECDSA signature can be represented using abi.encodePacked(r, s, v). Contract wallets may accept a different encoding, depending on their validation policy.

receiveWithAuthorization

Receives tokens using a signed authorization from the payer.

  • from
    • The payer and authorizer.
  • to
    • The recipient, which must match the caller under the receive-with-authorization semantics.
  • value
    • The amount of tokens to transfer.
  • validAfter
    • The Unix timestamp after which the authorization becomes valid.
  • validBefore
    • The Unix timestamp before which the authorization must be used.
  • nonce
    • The unique authorization identifier.
  • signature
    • Signature or authorization bytes accepted by the relevant wallet.

The additional caller check distinguishes this operation from transferWithAuthorization and helps protect recipient-controlled workflows against front-running.

The following cancellation function is optional.

js
/**
 * @notice Attempt to cancel an authorization
 * @param authorizer    Authorizer's address
 * @param nonce         Nonce of the authorization
 * @param signature     Unstructured bytes signature signed by an EOA wallet or a contract wallet
 */
function cancelAuthorization(
    address authorizer,
    bytes32 nonce,
    bytes memory signature
) external;

It cancels an existing authorization so that the corresponding nonce cannot subsequently be used to execute the authorized operation.

  • authorizer
    • The address that issued the authorization.
  • nonce
    • The nonce of the authorization being canceled.
  • signature
    • The signature bytes authorizing cancellation.

The associated AuthorizationCanceled event records cancellation, and CANCEL_AUTHORIZATION_TYPEHASH identifies the cancellation message type.

Rationale

The proposal generalizes the traditional v, r, s interface by supporting an opaque bytes parameter.

This allows developers to use a common token-transfer interface for both externally owned accounts and smart contract wallets while accommodating different validation policies and signature formats.

A smart contract does not necessarily produce an ECDSA signature itself. Its ERC-1271 implementation determines whether supplied authorization data is valid for a particular message hash.

Compatibility

Existing ERC-3009 integrations can continue to operate when the original function overloads are retained.

Supporting both interfaces

An implementation supporting both the traditional ECDSA parameters and the new bytes parameter can reduce duplicated validation logic by converting r, s, and v into the expected byte representation.

js
function transferWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    uint8 v,
    bytes32 r,
    bytes32 s
) external {
    transferWithAuthorization(
        from,
        to,
        value,
        validAfter,
        validBefore,
        nonce,
        abi.encodePacked(r, s, v)
    );
}

Both entry points should ultimately enforce the same authorization rules. The appropriate shared internal or public function must be available for the illustrated direct function call to compile.

Implementation

js
/**
  * @notice Execute a transfer with a signed authorization
  * @dev EOA wallet signatures should be packed in the order of r, s, v.
  * @param from          Payer's address (Authorizer)
  * @param to            Payee's address
  * @param value         Amount to be transferred
  * @param validAfter    The time after which this is valid (unix time)
  * @param validBefore   The time before which this is valid (unix time)
  * @param nonce         Unique nonce
  * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
  */
function _transferWithAuthorization(
    address from,
    address to,
    uint256 value,
    uint256 validAfter,
    uint256 validBefore,
    bytes32 nonce,
    bytes memory signature
) internal {
    require(now > validAfter, "Authorization is not yet valid");
    require(now < validBefore, "Authorization is expired");
    require(!_authorizationStates[authorizer][nonce], "Authorization is used or canceled");

    bytes32 digest = keccak256(abi.encodePacked(
        hex"1901",
        DOMAIN_SEPARATOR,
        keccak256(abi.encode(
            TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
            from,
            to,
            value,
            validAfter,
            validBefore,
            nonce
        ))
    ));
    require(
        // Check for both ECDSA signature and and ERC-1271 signature. A sample SignatureChecker is available at
        // https://github.com/OpenZeppelin/openzeppelin-contracts/blob/7bd2b2a/contracts/utils/cryptography/SignatureChecker.sol
        SignatureChecker.isValidSignatureNow(
            owner,
            typedDataHash,
            signature
        ),
        "Invalid signature"
    );

    _authorizationStates[authorizer][nonce] = true;
    emit AuthorizationUsed(authorizer, nonce);
    
    _transfer(from, to, value);
}

The example checks the validity period and nonce state, constructs an EIP-712 digest, validates the signature, consumes the nonce, and performs the transfer.

A compatible SignatureChecker can distinguish ECDSA-based account validation from ERC-1271 contract validation.

The excerpt is retained unchanged from the original article. It uses historical now syntax and inconsistent variable names, including authorizer, owner, typedDataHash, and digest. These must be reconciled with the intended authorizer and calculated message hash before compiling or using the example.

Security

Contract wallet signature validation

For contract-wallet authorizations, the security of transferWithAuthorization, receiveWithAuthorization, and cancelAuthorization depends on the wallet's signature-validation policy.

  • isValidSignature
    • Determines whether the supplied authorization is valid for the specified hash according to the wallet's policy.
  • transferWithAuthorization
    • Transfers tokens only after the corresponding authorization has been validated and the applicable nonce and time constraints have been checked.
  • receiveWithAuthorization
    • Performs equivalent authorization checks and additionally requires the recipient to match the caller.
  • cancelAuthorization
    • Validates the cancellation authorization before marking the corresponding nonce as unavailable.

Example

The original article includes the following illustrative wallet implementation.

solidity
contract ContractWallet {
    function isValidSignature(bytes32 hash, bytes memory signature) public view returns (bool) {
        // カスタム署名検証ロジック
        // 例:ECDSAで署名を検証する
        address signer = ECDSA.recover(hash, signature);
        return signer == owner;
    }
}

This excerpt illustrates owner-based ECDSA validation, but it is not a conforming ERC-1271 implementation as written. ERC-1271 defines a bytes4 return value and requires the magic value 0x1626ba7e for valid signatures, rather than a Boolean return value.

Summary

Wallet developers must carefully implement signature validation and ensure that the supplied hash corresponds to the intended action. Incorrect validation may authorize unintended transfers.

Token contracts must also enforce nonce uniqueness, validity windows, domain separation, and the distinct message types for transfers, receipt, and cancellation.

Contract signatures may become invalid when a wallet's authorization policy changes. Applications should not assume that a previously valid contract signature remains valid indefinitely.

The code examples are preserved from the original article and have not been independently compiled, executed, or audited as part of this translation. Japanese code comments remain unchanged.

Citation

Yvonne Zhang (@yvonnezhangc), Aloysius Chan (@circle-aloychan), "ERC-7598: Use contract signature for signed transfer [DRAFT]," Ethereum Improvement Proposals, no. 7598, January 2024. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-7598.

Conclusion

ERC-7598 extends ERC-3009 with flexible signature bytes and support for ERC-1271 validation, allowing contract wallets to participate in signed token-transfer workflows without requiring every wallet to use the same signature format.

Questions are welcome via Twitter @cardene777.

Other publications:

https://chaldene.net/