File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -325,7 +325,6 @@ def main(
325
325
usdt_address = to_checksum_address ("0x900101d06A7426441Ae63e9AB3B9b0F63Be145F1" ),
326
326
):
327
327
w3 = Web3Advanced (node_url = node_url )
328
- multicall = MultiCall (w3 = w3 )
329
328
330
329
with open ("abi/Counter.abi" ) as f :
331
330
counter_contract_abi = f .read ()
@@ -337,19 +336,18 @@ def main(
337
336
counter_contract = w3 .eth .contract (bytecode = counter_contract_bytecode , abi = counter_contract_abi )
338
337
usdt_contract = w3 .eth .contract (address = usdt_address , abi = erc20_abi )
339
338
339
+ # initializing new multicall
340
+ multicall = w3 .start_multicall ()
341
+
340
342
# calling an undeployed contract
341
- # '''
342
343
multicall .add_undeployed_contract (counter_contract .constructor (initialCounter = 13 ))
343
344
multicall .add_undeployed_contract_call (counter_contract .functions .counter ())
344
345
multicall .add_undeployed_contract_call (counter_contract .functions .updateCounter (newCounter = 7 ))
345
346
multicall .add_undeployed_contract_call (counter_contract .functions .counter ())
346
- # '''
347
347
348
- # '''
349
348
for _ in range (10_000 ):
350
349
# calling a deployed contract
351
350
multicall .add_call (usdt_contract .functions .decimals ())
352
- # '''
353
351
354
352
multicall_result = multicall .call ()
355
353
print (multicall_result )
Original file line number Diff line number Diff line change 4
4
from web3 .middleware import geth_poa_middleware
5
5
6
6
from .EthAdvanced import EthAdvanced
7
+ from .Multicall import MultiCall
7
8
8
9
9
10
class Web3Advanced (Web3 ):
@@ -60,6 +61,9 @@ def _construct_provider(node_url):
60
61
else :
61
62
raise ValueError (f"Unknown protocol for RPC URL { node_url } " )
62
63
64
+ def start_multicall (self ) -> MultiCall :
65
+ return MultiCall (w3 = self )
66
+
63
67
def _find_max_filter_range (self ):
64
68
current_block = self .eth .block_number
65
69
for filter_range in self .FILTER_RANGES_TO_TRY :
You can’t perform that action at this time.
0 commit comments