---
id: TIP-1122
title: Backward compatible SWAPN, DUPN, EXCHANGE
description: Adopts EIP-8024 extended stack instructions in Tempo.
authors: Dragan Rakita (@rakita)
status: Draft
related: EIP-8024
protocolVersion: TBD
---

# TIP-1122: Backward compatible SWAPN, DUPN, EXCHANGE

## Abstract

This TIP aligns Tempo with proposed Ethereum stack instructions by adopting
EIP-8024. It enables SWAPN, DUPN, and EXCHANGE so compilers can use the same
extended stack operations on both chains.

## Motivation

Keeping Tempo aligned with Ethereum reduces differences that application and
compiler authors need to support. This TIP includes:

- [EIP-8024: Backward compatible SWAPN, DUPN, EXCHANGE](https://eips.ethereum.org/EIPS/eip-8024)
  — adds stack operations that simplify compiler-generated code and deeper stack access.

# Specification

## EIP-8024: Backward compatible SWAPN, DUPN, EXCHANGE

Enable `DUPN` (`0xe6`), `SWAPN` (`0xe7`), and `EXCHANGE` (`0xe8`) in EVM bytecode,
each costing **3 gas**. Each opcode consumes one immediate byte, decoded exactly
as specified by
[EIP-8024](https://github.com/ethereum/EIPs/blob/24c0edb17b82cb65f26d29f03e084637ec2ae2d4/EIPS/eip-8024.md),
including its invalid immediate ranges and zero-padding at end of code.

Adopt the specified stack effects and exceptional failures, preserving the
1,024-item stack limit and existing jump-destination analysis. No EOF container
or bytecode version is required. Before activation these bytes retain their
previous invalid-opcode behavior when executed. Existing bytecode is not rewritten.

# Compatibility

The new opcodes require a coordinated network upgrade. Historical execution
retains its previous rules. Existing contracts keep their code and jump
destinations; execution of the newly assigned opcode bytes changes from
exceptional failure to the specified stack operations.
