www5226448 / web3s

A Python library for interacting with Ethereum and supporting asynchronous requests.
MIT License
11 stars 7 forks source link

KeyError: 'name' #2

Closed Nighty13 closed 3 years ago

Nighty13 commented 3 years ago

hello , is the library up to date? I'm trying to call contract functions , but I get this error : File "C:\Users\ALPHA\PycharmProjects\asyncWeb3\main.py", line 18, in main callcontract = await contract.functions.decimals().call() File "C:\Users\ALPHA\PycharmProjects\asyncWeb3\web3s\contract.py", line 1039, in call clone._set_function_info() File "C:\Users\ALPHA\PycharmProjects\asyncWeb3\web3s\contract.py", line 1044, in _set_function_info self.abi = find_matching_fn_abi( File "C:\Users\ALPHA\PycharmProjects\asyncWeb3\web3s\utils\contracts.py", line 97, in find_matching_fn_abi function_candidates = pipe(abi, *filters) File "cytoolz/functoolz.pyx", line 669, in cytoolz.functoolz.pipe return c_pipe(data, funcs) File "cytoolz/functoolz.pyx", line 644, in cytoolz.functoolz.c_pipe data = func(data) File "C:\Users\ALPHA\PycharmProjects\asyncWeb3\web3s\utils\abi.py", line 43, in filter_by_name return [ File "C:\Users\ALPHA\PycharmProjects\asyncWeb3\web3s\utils\abi.py", line 49, in abi['name'] == name KeyError: 'name'

Process finished with exit code 1

www5226448 commented 3 years ago

I can't analyze this issue.Please provide your script. It seems that you are fetching the decimal of the ERC20. It works well in my script.

` import asyncio import web3s w3 = web3s.Web3s(web3s.Web3s.HTTPProvider('')) contrats = w3.eth.contract('0xdAC17F958D2ee523a2206206994597C13D831ec7', abi=open('ERC20.txt').read()) call_contract = contrats.functions.balanceOf('0x5576FBC0910Cf6Ea812A63cE4E21Dc3Ee26F78B2').call() names=contrats.functions.name().call() d=contrats.functions.decimals().call() test_item = [w3.isConnected(), w3.eth.blockNumber, w3.eth.getBalance('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'),

         w3.eth.getStorageAt('0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', 0),
         w3.eth.getBlock(11117310),
         w3.eth.getBlockTransactionCount(11117310),
         w3.eth.getUncleByBlock(11117310, 0),
         w3.eth.getTransaction('0x39b416cdb762481a8a4ad70afaef10b52e59efcf52d13063a6554962a8c22e9f'),
         w3.eth.getTransactionByBlock(11117310, 0),
         w3.eth.waitForTransactionReceipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060'),
         w3.eth.getTransactionReceipt('0x5c504ed432cb51138bcf09aa5e8a410dd4a1e204ef84bfed1be16dfba1b22060'),
         # not yet mined
         w3.eth.getTransactionCount('0x39d9096Acb38D2E84409F6A384e662dcA3ba86Ee'),
         w3.eth.gasPrice,
         w3.eth.chainId,

         call_contract,
         names,d
         ]

async def main(): R=await asyncio.gather(*test_item) return R loop=asyncio.get_event_loop() r=loop.run_until_complete(main())

print(r[-3:]) `