---
eip: 2733
label: EIP-2733
title: Transaction Package
status: Withdrawn
type: Standards Track
category: Core
created: 2020-06-16
requires: 2718
official: https://eips.ethereum.org/EIPS/eip-2733
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2733.md
canonical: https://eips.huatuo.xyz/zh/eip-2733/
lang: zh
tldr: 一项已撤回的提案：新增一种交易类型，把多个已签名的交易打包成一个包并按顺序执行，让中继者可以代付 gas，且每一步都能看到上一步的结果。
tags: [transactions, core, meta-transactions, batching, withdrawn]
---

# EIP-2733: Transaction Package

> Creates a new transaction type which executes a package of one or more transactions, while passing status information to subsequent transactions.

**TL;DR:** 一项已撤回的提案：新增一种交易类型，把多个已签名的交易打包成一个包并按顺序执行，让中继者可以代付 gas，且每一步都能看到上一步的结果。

## 它解决什么问题？

新用户常常因为没有用于支付 gas 的 ETH 而无法在以太坊上发交易。通常的变通办法是元交易：用户签署一条消息，中继者把它提交给中继合约，合约验证签名并转发调用。这种做法很脆弱。中继合约必须自己恢复签名、自己跟踪 nonce，并且只把一部分 gas 传给内部调用，以便在内部调用 revert 时仍能完成后续操作（例如收取费用）。

EIP-2733 提议在协议层解决这个问题，方法是**交易包**：由赞助者为其他用户签署的一系列交易支付 gas，并按顺序原子地执行。

## 它如何运作

该提案定义了一种新的 [EIP-2718](/eip-2718/) 带类型交易（草案中为类型 `2`）：

- 外层的 **TransactionPackage** 由赞助者签名，包含 `chain_id`、`nonce`、`gas_price` 和一组子包。
- 每个 **ChildPackage** 由各自的发送者签名，包含该发送者的 `nonce`、一个 `max_gas_price` 以及一组 **ChildTransaction**（`to`、`value`、`data`、`gas_limit`，外加保留的 `flags` 和 `extra` 字段）。
- 子包的 `type` 为 `0x00` 时，签名覆盖包括 gas 上限在内的所有内容；为 `0x01` 时，gas 上限不在签名范围内，交由赞助者决定。
- 交易一个接一个地执行。每笔交易运行之前，上一笔交易的结果（`success`、`gas_used`、累计 gas、return data）会通过其第一个调用帧中的 `RETURNDATACOPY` 提供，从而实现条件流程。
- 每个子交易产生各自的回执；包的回执就是这些回执的列表。
- 草案中的固有成本为 `17000 + 8000 × children + data cost`。

## 示例代码

草案中描述的交易包的示意结构：

```text
TransactionPackage {            // signed by the sponsor (pays gas)
  chain_id, nonce, gas_price,
  children: [
    ChildPackage {              // signed by user A
      type: 0x00, nonce, max_gas_price,
      transactions: [
        { flags: 0, to: TokenA, value: 0, data: approve(...),  extra: 0x, gas_limit },
        { flags: 0, to: DEX,    value: 0, data: swap(...),     extra: 0x, gas_limit }
      ]
    }
  ],
  v, r, s
}

sig_hash = keccak256(rlp([2, chain_id, children, nonce, gas_price]))
```

## 需要注意

- 状态为 **Withdrawn**。作者给出的理由是转而推进 [EIP-3074](/eip-3074/)（`AUTH`/`AUTHCALL`）。
- EIP-3074 本身后来也被撤回。如今主网上的代付和批量交易来自 [EIP-7702](/eip-7702/)（EOA 委托给合约代码）和 [ERC-4337](/eip-4337/)（通过另一套内存池实现账户抽象）。
- 草案指出，检查 `ORIGIN == CALLER` 且返回数据为空的合约在交易包内的行为会有所不同，而内存池也需要谨慎处理，才能保持验证成本低廉。
- 类型 `2` 后来被分配给了 EIP-1559 的费用市场交易，因此这份草案中的类型编号如今已没有意义。


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-2733
