@@ -175,30 +175,30 @@ Most compilers for HLLs (solidity, serpent, viper, etc) on top of Ethereum have
175
175
176
176
You can initialize an ` abi.ContractTranslator ` object to encode and decode data for contracts as follows:
177
177
178
- true, false = True, False
179
- ct = abi.ContractTranslator(<json here>)
180
- txdata = ct.encode('function_name', [arg1, arg2, arg3])
178
+ true, false = True, False
179
+ ct = abi.ContractTranslator(<json here>)
180
+ txdata = ct.encode('function_name', [arg1, arg2, arg3])
181
181
182
182
You can also call ` ct.decode_event([topic1, topic2...], logdata) ` to decode a log.
183
183
184
184
### RLP encoding and decoding
185
185
186
186
For any transaction or block, you can simply do:
187
187
188
- import rlp
189
- bindata = rlp.encode(<tx or block>)
188
+ import rlp
189
+ bindata = rlp.encode(<tx or block>)
190
190
191
191
To decode:
192
192
193
- import rlp
194
- from ethereum.transactions import Transaction
195
- rlp.decode(blob, Transaction)
193
+ import rlp
194
+ from ethereum.transactions import Transaction
195
+ rlp.decode(blob, Transaction)
196
196
197
197
Or:
198
198
199
- import rlp
200
- from ethereum.blocks import Block
201
- rlp.decode(blob, Block)
199
+ import rlp
200
+ from ethereum.blocks import Block
201
+ rlp.decode(blob, Block)
202
202
203
203
### Consensus abstraction
204
204
@@ -223,15 +223,15 @@ Run `python3.6 -m pytest ethereum/tests/<filename>` for any .py file in that dir
223
223
224
224
To make your own state tests, use the tester module as follows:
225
225
226
- ``` python
227
- from ethereum.tools import tester as t
228
- import json
229
- c = t.Chain()
230
- x = c.contract(< code> , language = < language> )
231
- pre = t.mk_state_test_prefill(c)
232
- x.foo(< args> )
233
- post = t.mk_state_test_postfill(c, pre)
234
- open (' output.json' , ' w' ).write(json.dumps(post, indent = 4 ))
226
+ ```
227
+ from ethereum.tools import tester as t
228
+ import json
229
+ c = t.Chain()
230
+ x = c.contract(<code>, language=<language>)
231
+ pre = t.mk_state_test_prefill(c)
232
+ x.foo(<args>)
233
+ post = t.mk_state_test_postfill(c, pre)
234
+ open('output.json', 'w').write(json.dumps(post, indent=4))
235
235
```
236
236
237
237
To make a test filler file instead, do ` post = t.mk_state_test_postfill(c, pre, True) ` .
0 commit comments