-
Notifications
You must be signed in to change notification settings - Fork 13
evmdasm assembler
tintin edited this page Oct 20, 2018
·
6 revisions
Easily compile and manipulate evm bytecode using the EvmProgram interface
p = EvmProgram()
p.push(1)
p.push(0x0101)
p.op("JUMPDEST")
p.push(0xc0fefe)
#call.args: T.Gas("gas"), T.Address("address"), T.CallValue("value"), T.MemOffset("inOffset"), T.Length("inSize"), T.MemOffset("retOffset"), T.Length("retSize")
p.call(1,2,3,4,5,6,7)
# assemble the program --> EvmBytecode()
assembled = p.assemble()
# print as hexstring
assembled.as_hexstring # "60016101015b62c0fefe6001600260036004600560066007f1"
# disassemble the the bytecode --> EvmInstructions()
disassembled = assembled.disassemble()
# print the listing
disassembled.as_string
"""
PUSH1 01
PUSH2 0101
JUMPDEST
PUSH3 c0fefe
PUSH1 01
PUSH1 02
PUSH1 03
PUSH1 04
PUSH1 05
PUSH1 06
PUSH1 07
CALL
"""