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-6315 is a variation of ERC-2771 that removes the requirement for recipient contracts to trust individual forwarders.

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

ERC-6315 was in Draft status as of October 13, 2023.

Overview

ERC-2771 is a standard for meta-transactions that uses one or more trusted forwarders. ERC-6315 extends that model to support account abstraction without requiring recipients to trust those forwarders.

ERC-2771 allows operations to be executed through a trusted forwarder rather than directly by the original transaction signer. ERC-6315 introduces a different trust model for processing forwarded calls.

The extension gives Ethereum contracts more flexibility in how they identify accounts and process transactions.

For ERC-2771, see the following article.

ERC-2771: Understanding meta-transactions and third-party gas payments

Specification

The terms Trusted Forwarder and Recipient are interpreted according to ERC-2771.

Forwarder interface

javascript
pragma solidity ^0.8.0;

interface IForwarder {
    function isForwardedTransaction() external view returns (bool)
}

isForwardedTransaction

javascript
function isForwardedTransaction() external view returns (bool)

Overview

Determines whether the current call is a forwarded transaction.

Details

The recipient queries the calling contract to determine whether the call has been forwarded. Forwarded calls can receive different handling from ordinary calls.

Return value

  • bool
    • Returns true for a forwarded transaction and false otherwise.

A forwarded transaction reaches the recipient through another contract, the forwarder, rather than directly from the original sender. The recipient calls isForwardedTransaction on its caller to distinguish forwarded calls from ordinary ones. The implementation of the forwarder determines how it reports that status, for example through its execution context or an internal flag. The recipient can then apply the appropriate handling.

The declarations above are reproduced from the Japanese article; they omit Solidity's terminating semicolon and are illustrative rather than compilable as written.

Extracting the sender and forwarder

When a recipient function is called, the recipient must query the caller's isForwardedTransaction() function using staticcall. The result determines how the call is handled.

  1. If isForwardedTransaction() reverts or returns false:

    • Process the transaction normally.
    • Set the sender to the immediate caller.
    • Set the forwarder to the zero address.
  2. If isForwardedTransaction() returns true:

    • Treat the transaction as forwarded.
    • Extract the sender using the ERC-2771 procedure for extracting the transaction signer.
    • Set the forwarder to the immediate caller.

By checking isForwardedTransaction(), the recipient determines how to process the call and identifies both the sender and the forwarder. This supports special handling for meta-transactions.

staticcall

The EVM's STATICCALL operation allows a contract to call another contract without permitting state modifications in the resulting call context.

For example, contract A might need to retrieve an ERC-20 token balance. ERC-20 tokens are common in smart contracts, and querying their balances is a routine operation.

solidity
// ERC-20トークンのアドレス
address public tokenAddress = 0x12345...; // トークンのアドレス

// トークンの残高を取得する関数
function getTokenBalance(address _owner) public view returns (uint256) {
    // ERC-20トークンのbalanceOf関数をstaticcallで呼び出す
    (bool success, bytes memory data) = tokenAddress.staticcall(abi.encodeWithSignature("balanceOf(address)", _owner));
    require(success, "staticcall failed");
    
    // 戻り値を取り出して返す
    return abi.decode(data, (uint256));
}

In this example, contract A uses staticcall to invoke the ERC-20 token's balanceOf function and retrieves the balance of the specified address (_owner).

The important property is that the static call cannot modify state. It allows the contract to retrieve information from an external contract without allowing state changes in that call. It does not, however, guarantee that the external contract returns truthful data. The address placeholder in the example must also be replaced with a valid address before compilation.

For ERC-20, see the following article.

https://chaldene.net/erc20

Extending recipient contracts

When a recipient contract exposes a function that accepts an address parameter, it must introduce a corresponding function with the suffix Abstract.

Instead of a single address, this function accepts two addresses: the forwarder and an address controlled by that forwarder.

For functions accepting multiple address parameters, such as ERC-20's transferFrom, a single corresponding Abstract function can replace each address parameter with a pair of addresses. The original function behaves equivalently to the extended function with the forwarder address set to zero.

For example, an ERC-20 token would expose the following additional functions:

javascript
function transferAbstract(address toForwarder, address toAddress, uint256 amount);
function approveAbstract(address spenderForwarder, address spenderAddress, uint256 amount);
function transferFromAbstract(address fromForwarder, address fromAddress, address toForwarder, address toAddress, uint256 amount);

This extension lets recipients identify accounts by both their forwarder and the address controlled by that forwarder, allowing operations to distinguish accounts associated with different forwarders.

Rationale

Ethereum Improvement Proposals define improvements, features, and conventions for Ethereum.

Adding address parameters to commonly used interfaces is intended to maximize the general applicability of ERC-6315.

Extending common interfaces allows the proposal to apply across a wide range of applications. Compatibility with existing proposals is important when introducing new functionality. ERC-6315 therefore extends the existing interfaces with additional address parameters.

This approach makes the account model applicable to more smart contracts and protocols.

Backward compatibility

Existing contracts cannot use this proposal without implementing its extensions. The same limitation applies to ERC-2771 support in contracts that were not designed to handle it.

Security considerations

Recipients do not need to place special trust in forwarders. They can process ordinary transactions independently of any particular forwarder.

Users who choose a forwarder, however, must trust it. Their abstract account is associated with that forwarder, so the forwarder must process their transactions correctly and securely.

The proposal changes where trust is required rather than eliminating it entirely. Recipients distinguish accounts by forwarder and sender, while users remain responsible for trusting the forwarder associated with their account.

Citation

Gavin John (@Pandapip1), "ERC-6315: ERC-2771 Account Abstraction [DRAFT]," Ethereum Improvement Proposals, no. 6315, January 2023. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-6315.

Conclusion

ERC-6315 extends the ERC-2771 model so that recipient contracts do not need to trust individual forwarders, while users retain responsibility for their chosen forwarder.

Questions are welcome via Twitter @cardene777.

Other publications:

https://chaldene.net/