Skip to content

Commit

Permalink
Merge branch 'refactor' of github.com:defunctio/pyevmasm into refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
defunctio committed Jul 15, 2018
2 parents 2e556c6 + 42f0503 commit 8c6368b
Showing 1 changed file with 50 additions and 5 deletions.
55 changes: 50 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,53 @@
# pyevmasm

pyevmasm is an assembler and disassembler library for the Ethereum Virtual Machine (EVM). pyevmasm supports python 2.7 and newer.
pyevmasm is an assembler and disassembler library for the Ethereum Virtual Machine (EVM).

This library is currently new and under development.
## Examples
```
>>> from pyevmasm import instruction_table, disassemble_hex, disassemble_all, assemble_hex
>>> instruction_table[20]
Instruction(0x14, 'EQ', 0, 2, 1, 3, 'Equality comparision.', None, 0)
>>> instruction_table['EQ']
Instruction(0x14, 'EQ', 0, 2, 1, 3, 'Equality comparision.', None, 0)
>>> instrs = list(disassemble_all(binascii.unhexlify('608060405260043610603f57600035')))
>>> instrs.insert(1, instruction_table['JUMPI'])
>>> a = assemble_hex(instrs)
>>> a
'0x60805760405260043610603f57600035'
>>> print(disassemble_hex(a))
PUSH1 0x80
JUMPI
PUSH1 0x40
MSTORE
...
>>> assemble_hex('PUSH1 0x40\nMSTORE\n')
'0x604052'
```

New issues, feature requests, and contributions are welcome. Join us in #ethereum channel on the [Empire Hacking Slack](https://empireslacking.herokuapp.com) to discuss Ethereum security tool development.
## evmasm
`evmasm` is a commandline utility that uses pyevmasm to assemble or disassemble EVM.

# evmasm
evmasm is a commandline utility that uses pyevmasm to assemble or disassemble EVM. Below is an example of disassembling the preamble of compiled contract.
```
usage: evmasm [-h] (-a | -d | -t) [-bi] [-bo] [-i [INPUT]] [-o [OUTPUT]]
pyevmasm the EVM assembler and disassembler
optional arguments:
-h, --help show this help message and exit
-a, --assemble Assemble EVM instructions to opcodes
-d, --disassemble Disassemble EVM to opcodes
-t, --print-opcode-table
List supported EVM opcodes
-bi, --binary-input Binary input mode (-d only)
-bo, --binary-output Binary output mode (-a only)
-i [INPUT], --input [INPUT]
Input file, default=stdin
-o [OUTPUT], --output [OUTPUT]
Output file, default=stdout
```


Example; disassembling the preamble of compiled contract.
```
$ echo -n "608060405260043610603f57600035" | evmasm -d
00000000: PUSH1 0x80
Expand All @@ -25,6 +64,8 @@ $ echo -n "608060405260043610603f57600035" | evmasm -d

# Installation

Python >=2.7 or Python >=3.3 is required.

Install the latest stable version using pip:
```
pip install pyevmasm
Expand All @@ -37,3 +78,7 @@ cd pyevmasm
python setup.py install
```

## Documentation
[https://pyevmasm.readthedocs.io](https://pyevmasm.readthedocs.io)

New issues, feature requests, and contributions are welcome. Join us in #ethereum channel on the [Empire Hacking Slack](https://empireslacking.herokuapp.com) to discuss Ethereum security tool development.

0 comments on commit 8c6368b

Please sign in to comment.