Sponsored transactions—the separation of fee payment from transaction content—have been a long standing feature request. Unlike similar proposals, this EIP specifies a method of implementing sponsored transactions that allows both externally owned accounts (EOAs) and [EIP-2938](./eip-2938.md) contracts to act as sponsors.
With the explosion of tokens built on Ethereum, especially stable coins, it has become common for EOAs to hold valuable assets without holding any Ether at all. These assets must be converted to Ether before they can be used to pay gas fees, but without Ether to pay for the conversion, it's impossible to convert them. Sponsored transactions break the circular dependency.
While it is possible to emulate sponsored transactions (ex. [Gas Station Network](https://www.opengsn.org/)), these solutions require specific support in callee contracts.
## Specification
Sponsored transactions are implemented with the addition of two precompiles:
- The first, at address `0x13`, which functions like a `CALL` instruction that additionally sets the caller address based on an ECDSA signature.
`CALL_PRECOMPILE` returns a success in all other cases.
The return data of `CALL_PRECOMPILE` will be a single byte to indicate the status of the call into callee followed immediately by the return data from that call.
#### `NONCE_PRECOMPILE`
`NONCE_PRECOMPILE` requires the following two arguments:
Assuming the calldata is the correct length, `NONCE_PRECOMPILE` will return a success, and place the nonce associated with the address pair in the return data.
*`0xEEEE...EEEE` and `0xBBBB...BBBB` are the sponsee addresses; and
*`55` and `89` are the current nonce values for their respective pairs.
The nonce shall be incremented whenever a correctly signed transaction-like package containing the next nonce is submitted to `CALL_PRECOMPILE` with a sufficient gas limit.
### Gas Fees
#### `CALL_PRECOMPILE`
TODO: Probably something like the sum of:
* The cost of a normal call, including calldata and signature size, etc.
* An `SLOAD` to read the current nonce
* An `SSTORE` to write the updated nonce
* Cost of an ecrecover
#### `NONCE_PRECOMPILE`
TODO: Probably something like the sum of:
* An `SLOAD` to read the current nonce
## Rationale
### Another Sponsored Transaction EIP
Other approaches to sponsored transactions, which rely on introducing a new transaction type, are not immediately compatible with account abstraction (AA). These proposals require a _signed_ transaction from the sponsor's account, which is not possible from an AA contract, because it has no private key to sign with.
Besides better compatibility with AA, a precompile is a much less intrusive change than a new transaction type. This approach requires no changes in existing wallets, and little change in other tooling.
`CALL_PRECOMPILE`'s single purpose is to set `CALLER`. It implements the minimal functionality to enable sender abstraction for sponsored transactions. This single mindedness makes `CALL_PRECOMPILE` significantly more composable with existing Ethereum features.
More logic can be implemented around the call into `CALL_PRECOMPILE`, giving more control to invokers and sponsors without sacrificing security or user experience for sponsees.
- Use invoker nonce: every sponsored transaction from the invoker's account invalidates every other transaction-like package. Also interacts with `SELFDESTRUCT`.
Instead, by creating an independent nonce per invoker-sponsee pair, we get some attractive properties:
- A transaction package can only be invalidated if both the invoker and sponsee cooperate, which is nice for EOA sponsors, and necessary for AA contracts.
Opcodes do not have externally visible addresses, and therefore cannot be called directly by an EOA. Using a precompile allows a sponsor to avoid an intermediary contract call should they want to use this functionality directly.