Created
October 19, 2020 12:58
-
-
Save voith/f43d0e5eb0a2880c6c59beabcc4bd1af to your computer and use it in GitHub Desktop.
Example to add two numbers using the Ethereum virtual Machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from eth.vm.forks import ( | |
IstanbulVM, | |
) | |
from eth.vm import ( | |
opcode_values | |
) | |
from tests.core.opcodes.test_opcodes import ( | |
assemble, | |
CANONICAL_ADDRESS_B, | |
setup_computation, | |
) | |
code = assemble( | |
opcode_values.PUSH1, | |
0x1, | |
opcode_values.PUSH1, | |
0x1, | |
opcode_values.ADD | |
) | |
computation = setup_computation(IstanbulVM, CANONICAL_ADDRESS_B, code) | |
comp = computation.apply_message( | |
computation.state, | |
computation.msg, | |
computation.transaction_context, | |
) | |
result = comp.stack_pop1_any() | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment