EIP-5920 - PAY opcode

Created 2022-03-14
Status Draft
Category Core
Type Standards Track
Authors
Requires

Abstract

This EIP introduces a new opcode, PAY, taking two stack parameters, addr and val, that transfers val wei to the address addr without calling any of its functions.

Motivation

Currently, to send ether to an address requires you to call into that address, which transfers execution context to that address, which creates several issues:

Specification

Constants

Constant Definition
WARM_STORAGE_READ_COST EIP-2929
COLD_ACCOUNT_ACCESS_COST EIP-2929
GAS_NEW_ACCOUNT EELS
GAS_CALL_VALUE EELS

Behavior

A new opcode is introduced: PAY (0xfc), which:

Gas Cost

The gas cost for PAY is the sum of the following:

PAY cannot be implemented on networks with empty accounts (see EIP-7523).

Rationale

Argument order

The order of arguments mimics that of CALL, which pops addr before val. Beyond consistency, though, this ordering aids validators pattern-matching MEV opportunities, so PAY always appears immediately after COINBASE.

Halting for invalid address

The halting behavior is designed to allow for Address Space Extension. If the high bytes were truncated, as in CALL, contracts could depend on the truncating behavior. If the address space were extended beyond 20 bytes, PAY would either not be able to target those accounts, or code expecting truncation could send ether to the wrong address.

Because this behavior may be changed, contracts should not rely on this halting behavior and use other methods to intentionally halt (like the cheaper INVALID opcode).

Backwards Compatibility

This change requires a hard fork.

Security Considerations

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. It is also possible to involuntarily fund an account using priority fees. However, this opcode does make this process cheaper and easier for already-vulnerable contracts.

Copyright

Copyright and related rights waived via CC0.