Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to fix AttributeError: 'Web3' object has no attribute 'toChecksumAddress'?

I’m trying to use 1inch oracle methods from here. This is python wrapper around 1inch apis. I want to know token price from some oracle so i’m using oracle method "get_rate_to_ETH".

But in a result I have this exception:

Traceback (most recent call last):
  File "D:\projects\1inchArb\1inch_api.py", line 20, in <module>
    price_usdc = oracle.get_rate_to_ETH("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", src_token_decimal=6)
  File "D:\projects\1inchArb\venv\lib\site-packages\oneinch_py\main.py", line 376, in get_rate_to_ETH
    rate = self.oracle_contract.functions.getRateToEth(self.w3.toChecksumAddress(src_token), wrap).call()
AttributeError: 'Web3' object has no attribute 'toChecksumAddress'

My code:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

from oneinch_py import OneInchOracle


public_key = "my_wallet_addr"
rpc_url = "https://cloudflare-eth.com"

oracle = OneInchOracle(rpc_url, chain='ethereum')

price_usdc = oracle.get_rate_to_ETH("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", src_token_decimal=6)

Also I tried to use different RPC urls such as "https://mainnet.infura.io/v3/{}".format(my_infura_key) but it gives same error.

If anyone knows how to help me it would be very grateful…

>Solution :

Update to latests version оf 1inch.py – 1.9, released 20 March 2023 and also web3 to use version 6.0.0.

1inch.py is using web3 as dependency. web3 removed CamelCase naming in latest version 6.0.0

1inch.py released new version to change their code and migrate to using web3, version 6.0.0.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading