@@ -202,19 +202,19 @@ Given the following solidity source file stored at ``contract.sol``.
202202.. code-block :: javascript
203203
204204 contract StoreVar {
205-
205+
206206 uint8 public _myVar;
207207 event MyEvent (uint indexed _var);
208-
208+
209209 function setVar (uint8 _var ) public {
210210 _myVar = _var;
211211 MyEvent (_var);
212212 }
213-
213+
214214 function getVar () public view returns (uint8) {
215215 return _myVar;
216216 }
217-
217+
218218 }
219219
220220 The following example demonstrates a few things:
@@ -229,45 +229,45 @@ The following example demonstrates a few things:
229229 import sys
230230 import time
231231 import pprint
232-
232+
233233 from web3.providers.eth_tester import EthereumTesterProvider
234234 from web3 import Web3
235235 from solc import compile_source
236-
236+
237237
238238 def compile_source_file (file_path ):
239239 with open (file_path, ' r' ) as f:
240240 source = f.read()
241-
241+
242242 return compile_source(source)
243-
244-
243+
244+
245245 def deploy_contract (w3 , contract_interface ):
246246 tx_hash = w3.eth.contract(
247247 abi = contract_interface[' abi' ],
248248 bytecode = contract_interface[' bin' ]).deploy()
249-
249+
250250 address = w3.eth.getTransactionReceipt(tx_hash)[' contractAddress' ]
251251 return address
252-
253-
252+
253+
254254 w3 = Web3(EthereumTesterProvider())
255-
255+
256256 contract_source_path = ' contract.sol'
257257 compiled_sol = compile_source_file(' contract.sol' )
258-
258+
259259 contract_id, contract_interface = compiled_sol.popitem()
260-
260+
261261 address = deploy_contract(w3, contract_interface)
262262 print (" Deployed {0} to: {1} \n " .format(contract_id, address))
263-
263+
264264 store_var_contract = w3.eth.contract(
265265 address = address,
266266 abi = contract_interface[' abi' ])
267-
267+
268268 gas_estimate = store_var_contract.functions.setVar(255 ).estimateGas()
269269 print (" Gas estimate to transact with setVar: {0} \n " .format(gas_estimate))
270-
270+
271271 if gas_estimate < 100000 :
272272 print (" Sending transaction to setVar(255)\n " )
273273 tx_hash = store_var_contract.functions.setVar(255 ).transact()
0 commit comments