---
eip: 7877
label: EIP-7877
title: Enhanced RETURN opcodes
status: Stagnant
type: Standards Track
category: Core
created: 2025-01-31
requires: 6, 1153, 3855
official: https://eips.ethereum.org/EIPS/eip-7877
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7877.md
canonical: https://eips.huatuo.xyz/eip-7877/
lang: en
tldr: Proposes SRETURN, TRETURN and RRETURN opcodes that return data straight from storage, transient storage or return data, skipping the copy into memory that RETURN requires.
tags: [evm, opcode, gas, transient-storage, core]
---

# EIP-7877: Enhanced RETURN opcodes

> Deprecate RETURN opcode in favor of new opcodes that allow returning data from various locations without first having to write to memory.

**TL;DR:** Proposes SRETURN, TRETURN and RRETURN opcodes that return data straight from storage, transient storage or return data, skipping the copy into memory that RETURN requires.

## What problem does it solve?

`RETURN` can only return bytes from memory. If the data you want to return sits elsewhere, you first copy it into memory and then return it:

- With [EIP-1153](/eip-1153/) transient storage, many callbacks stash data in `TSTORE` and later return it, paying for `TLOAD` + `MSTORE` loops and memory expansion.
- Returning values held in persistent storage has the same overhead with `SLOAD`.
- Forwarding (part of) another call's return data needs `RETURNDATACOPY` into memory first.

EIP-7877 lets a contract name the source directly, which saves gas and makes the bytecode simpler to analyze.

## How it works

Three new opcodes, and `RETURN` gets an alias:

| Opcode | Byte | Returns |
| --- | --- | --- |
| `MRETURN` | `0xf3` | Memory (just a new name for `RETURN`, unchanged) |
| `SRETURN` | `0xf6` | Consecutive storage slots |
| `TRETURN` | `0xf7` | Consecutive transient-storage slots |
| `RRETURN` | `0xf8` | A slice of the current return-data buffer |

- **`SRETURN` / `TRETURN`** pop `slot` and `length`. They read `slot`, `slot+1`, ..., write each as its 32-byte big-endian word (exactly as `MSTORE` would), concatenate them and return the first `length` bytes. A partial final slot contributes only its leading bytes; unset slots read as zeros.
- **`RRETURN`** pops `offset` and `length` and returns `RETURNDATA[offset : offset+length]`. Out-of-bounds reads fail, with the same rules as `RETURNDATACOPY` ([EIP-211](/eip-211/)).

Proposed gas: `SRETURN` charges 2,100 per cold slot and 100 per warm slot; `TRETURN` 100 per slot; `RRETURN` like `RETURNDATACOPY` minus memory expansion (3 + 3 per word). The renaming has precedent in [EIP-6](/eip-6/) (`SUICIDE` to `SELFDESTRUCT`), and the gas-saving motive mirrors [EIP-3855](/eip-3855/) `PUSH0`.

## Sample code

Returning two words from transient storage, today vs. proposed (assembly pseudocode):

```solidity
// Today: copy to memory, then RETURN
assembly {
    mstore(0x00, tload(0))
    mstore(0x20, tload(1))
    return(0x00, 0x40)
}

// With EIP-7877 (not valid Solidity today; illustrative)
assembly {
    treturn(0, 0x40) // slots 0 and 1, 64 bytes, no memory touched
}
```

Opcode-level view:

```text
6040  PUSH1 0x40   // length = 64 bytes
5f    PUSH0        // slot = 0
f7    TRETURN
```

## Things to know

- Status: **Stagnant**. No upgrade has scheduled it, and the gas formulas are written as a rough proposal ("should be similar to the cost of accessing data now").
- The spec suggests activating it in a future EVM version once EOF is implemented; EOF itself has not shipped on mainnet.
- Existing contracts are unaffected: `MRETURN` is byte-for-byte the old `RETURN`.
- Compilers would need to adopt the opcodes before typical Solidity code benefits.


---

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