Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 41 additions & 36 deletions EIPS/eip-7997.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
eip: 7997
title: Deterministic Factory Contract
description: A minimal `CREATE2` factory shared by EVM chains.
author: Francisco Giordano (@frangio), Toni Wahrstätter (@nerolation), Nick Johnson (@Arachnid)
author: Francisco Giordano (@frangio), Toni Wahrstätter (@nerolation), Nick Johnson (@Arachnid), Jochem Brouwer (@jochem-brouwer)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: adding myself as author here, if this is too much will remove myself.

discussions-to: https://ethereum-magicians.org/t/eip-7997-deterministic-factory-predeploy/24998
status: Draft
type: Standards Track
Expand Down Expand Up @@ -44,41 +44,46 @@ A chain may satisfy this requirement by any means that results in the account ab

This is a contract that invokes the `CREATE2` instruction ([EIP-1014](./eip-1014.md)) with a salt equal to the first 32 bytes of the call's input data, init code equal to the remaining data, and value equal to the call's value. If input data is smaller than 32 bytes, the contract will attempt to copy close to 2^256 bytes of calldata and should revert as a result. If contract creation fails (`CREATE2` outputs `0`), the call reverts with empty return data. When successful, the address is returned in exactly 20 bytes of data with no padding.

The bytecode above decodes to the following mnemonics:

```
[00] PUSH32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0
[21] CALLDATASIZE
[22] ADD
[23] PUSH1 0x00
[25] DUP2
[26] PUSH1 0x20
[28] DUP3
[29] CALLDATACOPY
[2a] DUP1
[2b] CALLDATALOAD
[2c] DUP3
[2d] DUP3
[2e] CALLVALUE
[2f] CREATE2
[30] DUP1
[31] ISZERO
[32] ISZERO
[33] PUSH1 0x39
[35] JUMPI
[36] DUP2
[37] DUP3
[38] REVERT
[39] JUMPDEST
[3a] DUP1
[3b] DUP3
[3c] MSTORE
[3d] POP
[3e] POP
[3f] POP
[40] PUSH1 0x14
[42] PUSH1 0x0c
[44] RETURN
The above runtime bytecode disassembles to the following:

```asm
push32 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0
calldatasize
add

push1 0x00
dup2
push1 0x20
dup3
calldatacopy

dup1
calldataload

dup3
dup3
callvalue
create2
dup1
iszero
iszero
push1 0x39
jumpi

dup2
dup3
revert

jumpdest
dup1
dup3
mstore
pop
pop
pop
push1 0x14
push1 0x0c
return
```

## Rationale
Expand Down
Loading