EIP-5920: PAY opcode
Introduces a new opcode, PAY, to send ether to an address without calling any of its functions
|Authors||Gavin John (@Pandapip1), Zainan Victor Zhou (@xinbenlv)|
Table of Contents
This EIP introduces a new opcode,
PAY, taking two stack parameters,
val, that transfers
val wei to the address
addr without calling any of its functions.
Currently, to send ether to an address requires you to call a function of that address, which has a few issues. First of all, it opens a reentrancy attack vector, as the recipient can call back into the sender. Secondly, it opens a DoS vector, so parent functions must be cognizant of the possibility that the recipient will run out of gas or revert. Finally, the
CALL opcode is needlessly expensive for simple ether transfers, as it requires the memory and stack to be expanded, the recipient’s full data including code and memory to be loaded, and finally needs to execute a call, which might do other unintentional operations. Having a dedicated opcode for ether transfers solves all of these issues, and would be a useful addition to the EVM.
A new opcode is introduced:
- Pops two values from the stack:
valwei from the executing address to the address
addris the zero address, instead,
valwei is burned from the executing address.
The cost of this opcode is
addr is not the zero address, the EIP-2929 account access costs are also incurred (this includes the 25k gas cost for adding a new account to the state).
The gas pricing is that of a
CALL with a positive
msg.value, but without any memory expansion costs or “gas sent with call” costs, with a gas reduction of
500 to compensate for the reduced amount of computation.
The order of arguments mimicks that of
CALL, which pops
val. Beyond consistency, though, this ordering aids validators pattern-matching MEV opportunities, so
PAY always appears immediately after
This change requires a hard fork.
Existing contracts should not rely on their balance being under their control, since it is already possible to send ether to an address without calling it, by creating a temporary contract and immediately
SELFDESTRUCTing it, sending the ether to an arbitrary address. However, this opcode does make this process cheaper for already-vulnerable contracts.
Copyright and related rights waived via CC0.
Please cite this document as:
Gavin John (@Pandapip1), Zainan Victor Zhou (@xinbenlv), "EIP-5920: PAY opcode [DRAFT]," Ethereum Improvement Proposals, no. 5920, March 2022. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-5920.