EIP-5806 · Stagnant · Core · 2022-10-20
EIP-5806: Delegate transaction
A proposed transaction type that lets a regular EOA delegatecall a contract for one transaction, so it can batch calls and run arbitrary logic as itself without becoming a smart wallet.
What problem does it solve?
An externally owned account (EOA) can do only two things: send a call or deploy a contract. It cannot run custom logic as itself. That is why approving and then swapping a token takes two separate transactions, each with its own 21,000 gas overhead and fee, and with a window in which the open approval can be abused.
Smart contract wallets solve this, but most users still hold EOAs, and some assets cannot be moved to a new address. EIP-5806 proposes a small change: let an EOA perform a delegate call (the same mechanism contracts got in EIP-7) to a contract of its choosing, for the duration of one transaction. It explicitly does not aim to be a full account-abstraction design.
How it works
- A new EIP-2718 typed transaction (type number left as TBD) with the payload:
rlp([chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit, destination, data, access_list, y_parity, r, s]) - Fee fields follow EIP-1559 semantics. There is no
valuefield, anddestinationmust be a real address (it cannot be a contract creation). - Intrinsic gas is the same as an EIP-2930 transaction.
- Execution runs the code at
destinationin the context of the sender:address(this)is the EOA, events are emitted from the EOA, and any outgoingCALLhas the EOA asmsg.sender. - For safety, some opcodes throw when executed directly in the EOA context:
SSTORE: no storage on EOAs (avoids layout conflicts and future migration issues).CREATE,CREATE2,SELFDESTRUCT: these could change the EOA's nonce and break the "consecutive nonces" assumption. Contracts called from the delegated code are unaffected and may use these normally.
Sample code
The typical use is batching through a multicall-style contract. The delegated code runs as the EOA, so each sub-call's msg.sender is the user:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
/// Target for a delegate transaction. Uses no SSTORE/CREATE, as required.
contract Batch {
struct Call { address target; bytes data; }
function run(Call[] calldata calls) external {
for (uint256 i = 0; i < calls.length; i++) {
(bool ok, bytes memory ret) = calls[i].target.call(calls[i].data);
if (!ok) assembly { revert(add(ret, 32), mload(ret)) }
}
}
}
Conceptual transaction (pseudocode; the type byte was never assigned):
tx = DelegateTx(
chain_id, nonce, max_priority_fee_per_gas, max_fee_per_gas, gas_limit,
destination = Batch,
data = run([ (token, approve(router, amt)), (router, swap(...)) ]),
access_list = []
)
Things to know
- Status is Stagnant. It was never scheduled for a network upgrade.
- The goal of "let EOAs run code" was ultimately met by EIP-7702, which sets a delegation designator on the EOA instead of adding a one-shot delegate-call transaction. Use 7702 (or ERC-4337 smart accounts) for real deployments.
- Compared with EIP-3074, the user signs a whole transaction rather than a reusable authorization, so wallets can simulate exactly what will run.
- A delegate transaction gives the target code full power over the signer's assets. Wallets should only allow well-known, audited targets.