marusinm / eth-wallet

Python Ethereum wallet
MIT License
15 stars 16 forks source link

A quick one regarding contracts on main net #28

Closed mansilla closed 3 years ago

mansilla commented 3 years ago

Hey @marusinm , thank you for this code. I have a quick question. Do you know why I can't find a contract address when adding the token to the wallet? Using this code in the Ethereum Mainnet:

# TrueUSD contract (https://etherscan.io/address/0x0000000000085d4780b73119b644ae5ecd22b376)
contract_address = '0x0000000000085d4780b73119b644ae5ecd22b376' 
symbol ='TUSD'
try:
    api.add_contract(configuration, symbol, contract_address)
    print('New coin was added! %s %s' % (symbol, contract_address))
except InvalidAddress:
    print('Invalid contract address or wallet does not exist!')
except InfuraErrorException:
    print('Wallet is not connected to Ethereum network!')

this raises 'Invalid contract address or wallet does not exist!' On the other hand, I saw the comments on your code here: https://github.com/marusinm/eth-wallet/blob/master/eth_wallet/contract.py#L14. But actually, the Binance coin contract has a different address (https://etherscan.io/token/0xB8c77482e45F1F44dE1745F52C74426C631bDD52). So I'm kind of confused. Thank you in advance.

marusinm commented 3 years ago

@mansilla sorry for the late reply I don't maintain the project for a while.

Did you change the Ropsten testnet to the Mainnet in the configuration.py? https://github.com/marusinm/eth-wallet/blob/cc746de4123eefef5c3148120593151536e381ef/eth_wallet/configuration.py#L26 I admit this should be dynamic and configurable within CLI.

Your contract address on ETH mainnet is the same as an account address on the Ropsten testnet. Thats why you got 'Invalid contract address or wallet does not exist!'

The Binance coin contract that you found in my comment exists but again just in the Ropsten network: https://ropsten.etherscan.io/address/0x64bbf67a8251f7482330c33e65b08b835125e018

Sorry for this misconception with the comments, it is not 100% clean code. This repo was a school project, but feel free to open a PR. If you are using code from this repo in another project I will be happy to hear about it.

mansilla commented 3 years ago

Hey @marusinm no worries. Thanks for the reply. I was able to fix the issues finding the right addresses on the right network as you mentioned. Closing this now.