---
eip: 7705
label: EIP-7705
title: NONREENTRANT and REENTRANT opcodes
status: Stagnant
type: Standards Track
category: Core
created: 2024-05-09
official: https://eips.ethereum.org/EIPS/eip-7705
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-7705.md
canonical: https://eips.huatuo.xyz/eip-7705/
lang: en
tldr: Proposes two opcodes, NONREENTRANT and REENTRANT, that let a contract cheaply lock itself against incoming calls for the rest of a transaction.
tags: [evm, opcode, security, reentrancy, core]
---

# EIP-7705: NONREENTRANT and REENTRANT opcodes

> Opcodes to mark a contract as nonreentrant

**TL;DR:** Proposes two opcodes, NONREENTRANT and REENTRANT, that let a contract cheaply lock itself against incoming calls for the rest of a transaction.

## What problem does it solve?

Reentrancy, where a contract calls out and the callee calls back in before the first call finishes, is behind a large share of stolen funds on EVM chains, including the 2016 DAO hack. The usual defence is a reentrancy guard: write a "locked" flag to storage on entry and clear it on exit.

That costs gas on every protected function. Transient storage ([EIP-1153](/eip-1153/)) made guards cheaper, but the author argues it is still not cheap enough for developers to use it everywhere by default. EIP-7705 proposes to make the guard a native EVM feature.

## How it works

Two opcodes are added:

| Opcode | Byte | Gas | Effect |
| --- | --- | --- | --- |
| `NONREENTRANT` | `0xF6` | 5 | Set the current contract's nonreentrancy flag |
| `REENTRANT` | `0xF7` | 5 | Clear the flag |

While the flag is set, any `CALL`, `STATICCALL` or `DELEGATECALL` into that contract behaves as if the callee executed a single `REVERT`.

Rules:

- Both opcodes are idempotent (setting an already-set flag is a no-op).
- The flag lives only for the current transaction and is cleared at the end of it.
- If a call frame reverts or halts exceptionally, the flag rolls back to its value before that call, just like other state.

The spec mentions an alternative single-opcode design, a `NONREENTRANT` that takes a stack value to set or clear the flag, open for feedback.

## Sample code

Today's guard with transient storage, which the opcodes would replace:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

contract Vault {
    modifier nonReentrant() {
        assembly {
            if tload(0) { revert(0, 0) }
            tstore(0, 1)
        }
        _;
        assembly { tstore(0, 0) }
    }

    function withdraw(uint256 amount) external nonReentrant {
        // ... update balances, then send ETH
    }
}
```

What it would look like with EIP-7705, in pseudo-assembly (no compiler supports these opcodes):

```text
NONREENTRANT        ; 0xF6 - any call back into this contract now reverts
...                 ; checks, effects, external call
REENTRANT           ; 0xF7 - allow calls again
```

## Things to know

- **Status: Stagnant.** It has not been scheduled for any network upgrade, and its test cases, reference implementation and security considerations sections are empty.
- Note the semantics: the lock applies to the whole contract, not to a single function, and blocks *all* incoming calls, including view-style `STATICCALL`s, while set.
- Until something like this ships, use a well-reviewed guard (for example OpenZeppelin's `ReentrancyGuard` or its transient variant) and follow checks-effects-interactions.


---

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