✅Puzzle 7
CALLDATACOPY, CREATE
Puzzle
Solution
Chunk 1
At address 0x04
, we are calling CALLDATACOPY(0, 0, 16)
. This function call copies 16 bytes of calldata to the very beginning of the memory.
Chunk 2
At address 0x0A
, we are calling CREATE(0, 0, calldata_size)
. This function call creates a new contract and deposits 0 wei into it. The initialization code for the new contract is at memory location 0, which is our input copied during chunk 1. The return value of CREATE
is the new contract's address.
Chunk 3
This chunk tests if the new contract's code size is 1.
Chunk 4
If chunk 3 evaluates to true, then we are jumping to address 0x13
.
Building calldata
Since the new contract's code size must be 1, we can build a minimal contract that contains only 1 0x00
, which is the opcode for STOP
. In other word, the runtime code for this new contract is:
Write a creation code for it:
Compile in Playground:
Last updated