Skip to content

Commit 8c6368b

Browse files
committed
Merge branch 'refactor' of github.com:defunctio/pyevmasm into refactor
2 parents 2e556c6 + 42f0503 commit 8c6368b

File tree

1 file changed

+50
-5
lines changed

1 file changed

+50
-5
lines changed

README.md

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,53 @@
11
# pyevmasm
22

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

5-
This library is currently new and under development.
5+
## Examples
6+
```
7+
>>> from pyevmasm import instruction_table, disassemble_hex, disassemble_all, assemble_hex
8+
>>> instruction_table[20]
9+
Instruction(0x14, 'EQ', 0, 2, 1, 3, 'Equality comparision.', None, 0)
10+
>>> instruction_table['EQ']
11+
Instruction(0x14, 'EQ', 0, 2, 1, 3, 'Equality comparision.', None, 0)
12+
>>> instrs = list(disassemble_all(binascii.unhexlify('608060405260043610603f57600035')))
13+
>>> instrs.insert(1, instruction_table['JUMPI'])
14+
>>> a = assemble_hex(instrs)
15+
>>> a
16+
'0x60805760405260043610603f57600035'
17+
>>> print(disassemble_hex(a))
18+
PUSH1 0x80
19+
JUMPI
20+
PUSH1 0x40
21+
MSTORE
22+
...
23+
>>> assemble_hex('PUSH1 0x40\nMSTORE\n')
24+
'0x604052'
25+
```
626

7-
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.
27+
## evmasm
28+
`evmasm` is a commandline utility that uses pyevmasm to assemble or disassemble EVM.
829

9-
# evmasm
10-
evmasm is a commandline utility that uses pyevmasm to assemble or disassemble EVM. Below is an example of disassembling the preamble of compiled contract.
30+
```
31+
usage: evmasm [-h] (-a | -d | -t) [-bi] [-bo] [-i [INPUT]] [-o [OUTPUT]]
32+
33+
pyevmasm the EVM assembler and disassembler
1134
35+
optional arguments:
36+
-h, --help show this help message and exit
37+
-a, --assemble Assemble EVM instructions to opcodes
38+
-d, --disassemble Disassemble EVM to opcodes
39+
-t, --print-opcode-table
40+
List supported EVM opcodes
41+
-bi, --binary-input Binary input mode (-d only)
42+
-bo, --binary-output Binary output mode (-a only)
43+
-i [INPUT], --input [INPUT]
44+
Input file, default=stdin
45+
-o [OUTPUT], --output [OUTPUT]
46+
Output file, default=stdout
47+
```
48+
49+
50+
Example; disassembling the preamble of compiled contract.
1251
```
1352
$ echo -n "608060405260043610603f57600035" | evmasm -d
1453
00000000: PUSH1 0x80
@@ -25,6 +64,8 @@ $ echo -n "608060405260043610603f57600035" | evmasm -d
2564

2665
# Installation
2766

67+
Python >=2.7 or Python >=3.3 is required.
68+
2869
Install the latest stable version using pip:
2970
```
3071
pip install pyevmasm
@@ -37,3 +78,7 @@ cd pyevmasm
3778
python setup.py install
3879
```
3980

81+
## Documentation
82+
[https://pyevmasm.readthedocs.io](https://pyevmasm.readthedocs.io)
83+
84+
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 commit comments

Comments
 (0)