---
eip: 8219
label: EIP-8219
title: Checked Arithmetic Opcodes
status: Draft
type: Standards Track
category: Core
created: 2026-04-08
official: https://eips.ethereum.org/EIPS/eip-8219
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-8219.md
canonical: https://eips.huatuo.xyz/eip-8219/
lang: en
tldr: Proposes four EVM opcodes (SAFEADD, SAFESUB, SAFEMUL, SAFEDIV) that revert on overflow, underflow or division by zero, so the checked arithmetic Solidity and Vyper already emit costs a single instruction instead of a long check sequence.
tags: [evm, opcodes, arithmetic, gas, core]
---

# EIP-8219: Checked Arithmetic Opcodes

> Adds opcodes for addition, subtraction, multiplication, and division that revert on overflow, underflow, or division by zero

**TL;DR:** Proposes four EVM opcodes (SAFEADD, SAFESUB, SAFEMUL, SAFEDIV) that revert on overflow, underflow or division by zero, so the checked arithmetic Solidity and Vyper already emit costs a single instruction instead of a long check sequence.

## What problem does it solve?

Since Solidity 0.8, and in Vyper from the start, every `a + b` on a `uint256` is *checked*: if it overflows, the transaction reverts. The EVM has no native support for this, so compilers wrap each operation in several extra instructions and jumps. The author's benchmark on an ERC-20 `transfer` measured about 79 gas for one checked addition in Solidity (about 41 in Vyper), versus 3 gas for a raw `ADD`.

That overhead tempts developers to use `unchecked { }` or `unsafe_add()` to save gas, sometimes where it is not actually safe. EIP-8219 aims to make safety cheap enough that there is no reason to opt out.

## How it works

Four new opcodes fill the unused slots right after the existing arithmetic group:

| Opcode | Name | Gas | Reverts when |
| --- | --- | --- | --- |
| `0x0c` | `SAFEADD` | 5 | `a + b` exceeds 2²⁵⁶ − 1 |
| `0x0d` | `SAFESUB` | 5 | `b > a` (result would be negative) |
| `0x0e` | `SAFEMUL` | 7 | `a ≠ 0` and `a × b` exceeds 2²⁵⁶ − 1 |
| `0x0f` | `SAFEDIV` | 7 | `b == 0` |

- Stack order matches `ADD`/`SUB`/`MUL`/`DIV`: `a` on top, `b` below, result `a op b`.
- On error the current call frame **reverts with empty returndata**, exactly like `REVERT(0, 0)`. It does not consume all remaining gas the way an invalid opcode would, which matters for normal guard paths such as slippage checks.
- Each opcode is stateless. Earlier proposals ([EIP-1051](/eip-1051/), [EIP-6888](/eip-6888/)) used overflow/carry flags that must be read and branched on afterward; this design avoids hidden state and the risk of a flag being silently overwritten.
- Only unsigned 256-bit arithmetic is covered. Signed variants are left to a separate EIP.

## Sample code

Checked addition today versus with `SAFEADD` (EVM assembly, simplified):

```text
; today: roughly what a compiler emits for a checked add
DUP2 DUP2 ADD          ; a+b
DUP1 DUP3 GT           ; overflow if a > a+b
PUSH2 <panic> JUMPI
SWAP2 POP POP

; with EIP-8219
SAFEADD                ; 0x0c - pushes a+b or reverts(0,0)
```

Reference semantics, matching the spec's pseudocode:

```python
MAX = 2**256 - 1

def safeadd(a, b):
    r = (a + b) & MAX
    if r < a: raise Revert(b"")
    return r

def safesub(a, b):
    if b > a: raise Revert(b"")
    return a - b

def safemul(a, b):
    if a == 0: return 0
    r = (a * b) & MAX
    if r // a != b: raise Revert(b"")
    return r

def safediv(a, b):
    if b == 0: raise Revert(b"")
    return a // b
```

## Things to know

- **Status: Draft.** No fork is scheduled (`FORK_BLOCK` is TBD), and compilers would only use the opcodes when targeting an EVM version that has them.
- Existing `ADD`, `SUB`, `MUL` and `DIV` are unchanged. Code compiled for older EVM versions behaves the same.
- Solidity today reverts with `Panic(0x11)` on overflow. These opcodes return empty data instead, so tools that decode the panic code would see a different revert payload.
- The gas figures quoted come from the author's benchmarks with specific compiler versions; real savings depend on the compiler and code.


---

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