Skip to content

Instantly share code, notes, and snippets.

@stong
Last active August 22, 2022 23:53
Show Gist options
  • Save stong/6e49edc8a64eac16cd51043ac3143f68 to your computer and use it in GitHub Desktop.
Save stong/6e49edc8a64eac16cd51043ac3143f68 to your computer and use it in GitHub Desktop.
EVM universal constructor
cast rpc eth_sendTransaction '{"data": "'$(cat constructor_bytecode.txt)$(cat bytecode.txt)'"}'
0x600D380380600D6000396000F3
00: 60 0D ; push 0x0D (size of deployer code)
02: 38 ; codesize
03: 03 ; sub (top of stack is now size of code to deploy)
04: 80 ; dup1
05: 60 0D ; push 0x0D (size of deployer code)
07: 60 00 ; push 0 (codecopy dst offset)
09: 39 ; codecopy (0, 0x0d, codesize-0x0d)
0A: 60 00 ; push 0 (return mem offset)
0C: F3 ; ret (0, codesize-0x0d)
0D: rest of your bytecode goes here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment