EIP-3508 · Stagnant · Core · 2021-04-16
EIP-3508: Transaction Data Opcodes
A stagnant proposal for ORIGINDATALOAD/SIZE/COPY opcodes that let any contract in a call chain read the original transaction's data directly instead of having it passed along.
What problem does it solve?
When a contract calls another contract, any large data the callee needs (a Merkle proof, a batch of orders, a layer-2 payload) has to be copied into the new call's calldata. In multi-contract systems the same bytes may be re-encoded and copied several times, burning gas at every hop.
EIP-3508 proposed letting any contract read the original transaction's data directly, the same way ORIGIN exposes the original sender. Contracts deep in a call chain could then pull what they need from the transaction payload instead of receiving it through every intermediate call.
How it works
Three new opcodes mirroring the existing calldata ones:
| New opcode | Mirrors | Gas |
|---|---|---|
ORIGINDATALOAD (0x47) |
CALLDATALOAD (0x35) |
G_verylow |
ORIGINDATASIZE (0x48) |
CALLDATASIZE (0x36) |
G_base |
ORIGINDATACOPY (0x49) |
CALLDATACOPY (0x37) |
G_base + G_verylow per word |
They operate on the top-level transaction's data. If an AUTHCALL from EIP-3074 is on the call stack, they instead see the calldata of the nearest AUTHCALL, so that contracts relying on origin data would not exclude sponsored or relayed calls.
Sample code
Illustrative only: a contract deep in a call chain reads the first word of the transaction payload. origindataload is hypothetical; these opcodes were never activated and current Solidity will not compile this:
// Hypothetical: ORIGINDATA* do not exist on any live network
function firstWordOfTx() external view returns (bytes32 w) {
assembly {
w := origindataload(0) // like calldataload(0), but for tx.data
}
}
Equivalent semantics in pseudocode:
def origindataload(evm, offset):
data = nearest_authcall_args(evm) or evm.tx.data
evm.stack.push(int.from_bytes(data[offset:offset+32].ljust(32, b"\0"), "big"))
Things to know
- Status is Stagnant; the opcodes were never adopted.
- The opcode numbers it chose are now used by other instructions:
0x47isSELFBALANCE,0x48isBASEFEE,0x49isBLOBHASH. A revival would need new numbers. - The spec assumed EIP-3074 would ship in London; it did not, and 3074 was later withdrawn in favour of EIP-7702.
- Security caveat from the spec: never assume
tx.dataequals your calldata. Anyone can wrap the call in an entry contract, so origin data alone is not a trustworthy introspection tool. - The spec itself expects gas savings to be negligible for most real systems, since they mostly pass storage-derived values, not raw input.