{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/web3.py/issues/752","repository_url":"https://api.github.com/repos/ethereum/web3.py","labels_url":"https://api.github.com/repos/ethereum/web3.py/issues/752/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/web3.py/issues/752/comments","events_url":"https://api.github.com/repos/ethereum/web3.py/issues/752/events","html_url":"https://github.com/ethereum/web3.py/issues/752","id":312223720,"number":752,"title":"Unable to call contract mapping from web3 4.0.0","user":{"login":"Netherdrake","id":3516903,"avatar_url":"https://avatars1.githubusercontent.com/u/3516903?v=4","gravatar_id":"","url":"https://api.github.com/users/Netherdrake","html_url":"https://github.com/Netherdrake","followers_url":"https://api.github.com/users/Netherdrake/followers","following_url":"https://api.github.com/users/Netherdrake/following{/other_user}","gists_url":"https://api.github.com/users/Netherdrake/gists{/gist_id}","starred_url":"https://api.github.com/users/Netherdrake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Netherdrake/subscriptions","organizations_url":"https://api.github.com/users/Netherdrake/orgs","repos_url":"https://api.github.com/users/Netherdrake/repos","events_url":"https://api.github.com/users/Netherdrake/events{/privacy}","received_events_url":"https://api.github.com/users/Netherdrake/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-07T16:55:45Z","updated_at":"2018-04-09T15:30:28Z","closed_at":"2018-04-07T17:05:32Z","author_association":"NONE","body":"Setup:\r\n```python\r\ninfura_url = f'https://{ETH_CHAIN}.infura.io/{INFURA_KEY}'\r\nw3 = web3.Web3(web3.HTTPProvider(infura_url))\r\n\r\nc = w3.eth.contract(\r\n    address=VIDEO_PUBLISHER_ADDRESS,\r\n    abi=VIDEO_PUBLISHER_ABI,\r\n)\r\n```\r\nLets establish its setup:\r\n```\r\nIn [12]: c.address\r\nOut[12]: '0x22db6D760036166FAF677e216fE64a4D5E9B83E9'\r\n\r\nIn [13]: c.abi\r\nOut[13]: \r\n[{'constant': True,\r\n  'inputs': [],\r\n  'name': 'viewToken',\r\n  'outputs': [{'name': '', 'type': 'address'}],\r\n  'payable': False,\r\n  'stateMutability': 'view',\r\n  'type': 'function'},\r\n {'constant': True,\r\n  'inputs': [],\r\n  'name': 'price',\r\n  'outputs': [{'name': '', 'type': 'uint256'}],\r\n  'payable': False,\r\n  'stateMutability': 'view',\r\n  'type': 'function'},\r\n {'constant': True,\r\n  'inputs': [{'name': '', 'type': 'bytes12'}],\r\n  'name': 'videos',\r\n  'outputs': [{'name': '', 'type': 'bool'}],\r\n  'payable': False,\r\n  'stateMutability': 'view',\r\n  'type': 'function'},\r\n {'inputs': [{'name': 'viewToken_', 'type': 'address'},\r\n   {'name': 'price_', 'type': 'uint256'}],\r\n  'payable': False,\r\n  'stateMutability': 'nonpayable',\r\n  'type': 'constructor'},\r\n {'payable': True, 'stateMutability': 'payable', 'type': 'fallback'},\r\n {'anonymous': False,\r\n  'inputs': [{'indexed': False, 'name': 'videoID', 'type': 'bytes12'},\r\n   {'indexed': False, 'name': 'price', 'type': 'uint256'}],\r\n  'name': 'Published',\r\n  'type': 'event'},\r\n {'anonymous': False,\r\n  'inputs': [{'indexed': True, 'name': 'authority', 'type': 'address'}],\r\n  'name': 'LogSetAuthority',\r\n  'type': 'event'},\r\n {'anonymous': False,\r\n  'inputs': [{'indexed': True, 'name': 'owner', 'type': 'address'}],\r\n  'name': 'LogSetOwner',\r\n  'type': 'event'},\r\n {'constant': False,\r\n  'inputs': [{'name': 'videoID', 'type': 'bytes12'}],\r\n  'name': 'publish',\r\n  'outputs': [],\r\n  'payable': False,\r\n  'stateMutability': 'nonpayable',\r\n  'type': 'function'}]\r\n\r\n```\r\n\r\nLets say I want to call into a mapping called `videos`.\r\n```\r\npragma solidity ^0.4.2;\r\n\r\ncontract VideoPublisher is DSAuth, DSMath {\r\n    uint public price;\r\n    mapping (bytes12 => bool) public videos;\r\n    ...\r\n}\r\n```\r\n\r\nCalling a simple value works fine:\r\n```\r\nIn [20]: c.functions.price().call()\r\nOut[20]: 10000000000000000000\r\n```\r\n\r\nHowever for the mapping, nothing seems to work.\r\n```\r\nIn [21]: c.functions.videos().call('foo')\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-21-2c5dea161b09> in <module>()\r\n----> 1 c.functions.videos().call('foo')\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/contract.py in __init__(self, *args, **kwargs)\r\n    901             self.kwargs = kwargs\r\n    902         self.fn_name = type(self).__name__\r\n--> 903         self._set_function_info()\r\n    904 \r\n    905     def _set_function_info(self):\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/contract.py in _set_function_info(self)\r\n    907                                         self.function_identifier,\r\n    908                                         self.args,\r\n--> 909                                         self.kwargs)\r\n    910 \r\n    911         if self.function_identifier is FallbackFn:\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/contracts.py in find_matching_fn_abi(abi, fn_identifier, args, kwargs)\r\n     98         return function_candidates[0]\r\n     99     if not function_candidates:\r\n--> 100         raise ValueError(\"No matching functions found\")\r\n    101     else:\r\n    102         raise ValueError(\"Multiple functions found\")\r\n\r\nValueError: No matching functions found\r\n\r\nIn [22]: c.functions.videos('foo').call()\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-22-ff075bfba619> in <module>()\r\n----> 1 c.functions.videos('foo').call()\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/contract.py in __init__(self, *args, **kwargs)\r\n    901             self.kwargs = kwargs\r\n    902         self.fn_name = type(self).__name__\r\n--> 903         self._set_function_info()\r\n    904 \r\n    905     def _set_function_info(self):\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/contract.py in _set_function_info(self)\r\n    907                                         self.function_identifier,\r\n    908                                         self.args,\r\n--> 909                                         self.kwargs)\r\n    910 \r\n    911         if self.function_identifier is FallbackFn:\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/contracts.py in find_matching_fn_abi(abi, fn_identifier, args, kwargs)\r\n     98         return function_candidates[0]\r\n     99     if not function_candidates:\r\n--> 100         raise ValueError(\"No matching functions found\")\r\n    101     else:\r\n    102         raise ValueError(\"Multiple functions found\")\r\n\r\nValueError: No matching functions found\r\n\r\nIn [23]: c.functions.videos.call('foo')\r\n---------------------------------------------------------------------------\r\nAttributeError                            Traceback (most recent call last)\r\n<ipython-input-23-2903dd3a8ace> in <module>()\r\n----> 1 c.functions.videos.call('foo')\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/contract.py in call(self, transaction, block_identifier)\r\n    951             raise ValueError(\"Cannot set data in call transaction\")\r\n    952 \r\n--> 953         if self.address:\r\n    954             call_transaction.setdefault('to', self.address)\r\n    955         if self.web3.eth.defaultAccount is not empty:\r\n\r\nAttributeError: 'str' object has no attribute 'address'\r\n\r\nIn [24]: c.call().videos('foo')\r\n/home/user/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/decorators.py:14: DeprecationWarning: call is deprecated in favor of contract.<functions/events>.<method name>.call\r\n  return self.method(obj, *args, **kwargs)\r\n---------------------------------------------------------------------------\r\nValueError                                Traceback (most recent call last)\r\n<ipython-input-24-397f9df90be0> in <module>()\r\n----> 1 c.call().videos('foo')\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/contract.py in call_contract_function(abi, web3, address, normalizers, function_identifier, transaction, block_id, *args, **kwargs)\r\n   1199         fn_args=args,\r\n   1200         fn_kwargs=kwargs,\r\n-> 1201         transaction=transaction,\r\n   1202     )\r\n   1203 \r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/contracts.py in prepare_transaction(abi, address, web3, fn_identifier, fn_args, fn_kwargs, transaction)\r\n    170         fn_identifier,\r\n    171         fn_args,\r\n--> 172         fn_kwargs,\r\n    173     )\r\n    174     return prepared_transaction\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/contracts.py in encode_transaction_data(abi, web3, fn_identifier, args, kwargs)\r\n    180     elif is_text(fn_identifier):\r\n    181         fn_abi, fn_selector, fn_arguments = get_function_info(\r\n--> 182             abi, fn_identifier, args, kwargs\r\n    183         )\r\n    184     else:\r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/contracts.py in get_function_info(abi, fn_name, args, kwargs)\r\n    201         kwargs = {}\r\n    202 \r\n--> 203     fn_abi = find_matching_fn_abi(abi, fn_name, args, kwargs)\r\n    204     fn_selector = encode_hex(function_abi_to_4byte_selector(fn_abi))\r\n    205 \r\n\r\n~/.pyenv/versions/3.6.5/envs/general/lib/python3.6/site-packages/web3/utils/contracts.py in find_matching_fn_abi(abi, fn_identifier, args, kwargs)\r\n     98         return function_candidates[0]\r\n     99     if not function_candidates:\r\n--> 100         raise ValueError(\"No matching functions found\")\r\n    101     else:\r\n    102         raise ValueError(\"Multiple functions found\")\r\n\r\nValueError: No matching functions found\r\n```\r\n\r\nThe functions:\r\n```\r\nIn [27]: list(c.functions)\r\nOut[27]: ['price', 'videos', 'publish', ...]\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/ethereum/web3.py/issues/comments/379793302","html_url":"https://github.com/ethereum/web3.py/issues/752#issuecomment-379793302","issue_url":"https://api.github.com/repos/ethereum/web3.py/issues/752","id":379793302,"user":{"login":"pipermerriam","id":824194,"avatar_url":"https://avatars3.githubusercontent.com/u/824194?v=4","gravatar_id":"","url":"https://api.github.com/users/pipermerriam","html_url":"https://github.com/pipermerriam","followers_url":"https://api.github.com/users/pipermerriam/followers","following_url":"https://api.github.com/users/pipermerriam/following{/other_user}","gists_url":"https://api.github.com/users/pipermerriam/gists{/gist_id}","starred_url":"https://api.github.com/users/pipermerriam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pipermerriam/subscriptions","organizations_url":"https://api.github.com/users/pipermerriam/orgs","repos_url":"https://api.github.com/users/pipermerriam/repos","events_url":"https://api.github.com/users/pipermerriam/events{/privacy}","received_events_url":"https://api.github.com/users/pipermerriam/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T15:30:28Z","updated_at":"2018-04-09T15:30:28Z","author_association":"MEMBER","body":"@Netherdrake https://github.com/ethereum/web3.py/issues/757 to improve error messaging around this issue."}}
{"actor":{"display_login":"pipermerriam"}}