How to fix AttributeError: 'Web3' object has no attribute 'toChecksumAddress'?
Question:
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:projects1inchArb1inch_api.py", line 20, in <module>
price_usdc = oracle.get_rate_to_ETH("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", src_token_decimal=6)
File "D:projects1inchArbvenvlibsite-packagesoneinch_pymain.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:
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…
Answers:
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.
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:projects1inchArb1inch_api.py", line 20, in <module>
price_usdc = oracle.get_rate_to_ETH("0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", src_token_decimal=6)
File "D:projects1inchArbvenvlibsite-packagesoneinch_pymain.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:
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…
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.