I’m trying to interact with the TrustUSD token contract using web3.py. My code is as follows:
from ethtoken.abi import EIP20_ABI
from web3 import Web3, HTTPProvider
w3 = Web3(HTTPProvider("https://ropsten.infura.io/v3/<project_id>"))
tusd_address = "0x0000000000085d4780B73119b644AE5ecd22b376" # as listed here: https://github.com/trusttoken/smart-contracts
contract = w3.eth.contract(address=tusd_address, abi=EIP20_ABI)
but I’m receiving the following error:
BadFunctionCallOutput: Could not transact with/call contract function, is contract deployed correctly and chain synced?
Obviously, I’m missing something, but not a clue of what’s going on. Any help here guys?
Thanks in advance.
Hello, I see you’re using the Ropsten network.
The token contract for tusd on the mainnet and ropsten would be different.
Given this a try https://ropsten.etherscan.io/token/0x8d4eae2cbe4e5faa8d95db7b4887703ada5c3edc
Hey @Lily , thank you for your kind answer.
A gave a try to that address
tusd_address = "0x8d4eae2cbe4e5faa8d95db7b4887703ada5c3edc"
and is even weirder now to me since I’m receiving a different error using the same code above
InvalidAddress: ('Web3.py only accepts checksum addresses. The software that gave you this non-checksum address should be considered unsafe, please file it as a bug on their platform. Try using an ENS name instead. Or, if you must accept lower safety, use Web3.toChecksumAddress(lower_case_address).', '0x8d4eae2cbe4e5faa8d95db7b4887703ada5c3edc')
With this kind of error, you can try converting the address to checksum addresses using the address helper https://web3py.readthedocs.io/en/stable/web3.main.html#web3.Web3.toChecksumAddress
This article has a pretty good explanation for checksum and non-checksum addresses. https://web3py.readthedocs.io/en/stable/web3.main.html#web3.Web3.toChecksumAddress