diff --git a/EIPS/eip-7793.md b/EIPS/eip-7793.md new file mode 100644 index 0000000000000..f6b198efd18ea --- /dev/null +++ b/EIPS/eip-7793.md @@ -0,0 +1,64 @@ +--- +eip: 7793 +title: TXINDEX opcode +description: Opcode to get index of transaction within block +author: Marc Harvey-Hill (@Marchhill), Ahmad Bitar (@smartprogrammer93) +discussions-to: https://ethereum-magicians.org/t/eip-7793-txindex-opcode/21513 +status: Draft +type: Standards Track +category: Core +created: 2024-10-17 +--- + +## Abstract + +This EIP proposes to add a new opcode that returns the index of the transaction being executed within the current block. + +## Motivation + +The new opcode aims to improve support for encrypted mempools. In order to be secure, the validity of encrypted mempool transactions should be tied to the inclusion of all transactions by a proposer in the correct slot, and following the ordering rules. If these rules are not enshrined as block validity conditions then they can be enforced by a smart contract. + +This proposal enables smart contract solutions to check their own transaction index, so they can enforce inclusion at the correct index. These out-of-protocol solutions could be used for experimentation until a design appropriate for enshrinement is agreed upon. + +## Specification + +### `TXINDEX` (`TBD`) + +A new opcode `TXINDEX` shall be created at `TBD`. It shall return one stack element. + +#### Output + +##### Stack + +| Stack | Value | +| ---------- | -------------| +| `top - 0` | `Index` | + +`Index` is a 4 byte uint in big endian encoding. + +#### Gas Cost + +The gas cost for `TXINDEX` is a fixed fee of `2` + +## Rationale + +### Gas Price + +Similar opcodes are considered part of the `W_base` set. + +## Backwards Compatibility + +No backward compatibility issues found. + +## Test Cases + +N/A + +## Security Considerations + + +Needs discussion. + +## Copyright + +Copyright and related rights waived via [CC0](../LICENSE.md).