ethereum / web3.py

A python interface for interacting with the Ethereum blockchain and ecosystem.
http://web3py.readthedocs.io
MIT License
5.01k stars 1.71k forks source link

The method eth_coinbase does not exist/is not available #1866

Closed mapapuche closed 3 years ago

mapapuche commented 3 years ago
aiodns==1.1.1
aiohttp==3.7.2
async-timeout==3.0.1
attrs==19.3.0
autobahn==20.7.1
Automat==20.2.0
base58==2.1.0
bitarray==1.2.2
ccxt==1.41.32
certifi==2020.6.20
cffi==1.14.0
chardet==3.0.4
constantly==15.1.0
coverage==5.4
cryptography==3.0
cytoolz==0.11.0
dateparser==0.7.6
decorator==4.4.2
eth-abi==2.1.1
eth-account==0.5.4
eth-hash==0.3.1
eth-keyfile==0.5.1
eth-keys==0.3.3
eth-rlp==0.2.1
eth-typing==2.2.2
eth-utils==1.10.0
etherscan-python==2.0.2
hexbytes==0.2.1
hyperlink==19.0.0
idna==2.10
idna-ssl==1.1.0
incremental==17.5.0
ipfshttpclient==0.7.0a1
jsonschema==3.2.0
lru-dict==1.1.6
multiaddr==0.0.9
multidict==4.7.6
netaddr==0.8.0
numpy==1.20.0
parsimonious==0.8.1
pkg-resources==0.0.0
protobuf==3.14.0
pyaes==1.6.1
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycares==3.1.1
pycparser==2.20
pycryptodome==3.9.9
pydash==4.8.0
PyHamcrest==2.0.2
PyJWT==1.7.1
pyOpenSSL==19.1.0
pyrsistent==0.17.3
python-binance==0.7.5
python-dateutil==2.8.1
python-kucoin==2.1.2
python-quoine==0.1.4
python-telegram-bot==12.8
pytz==2020.1
regex==2020.7.14
requests==2.24.0
rlp==2.0.1
rsa==4.6
scipy==1.6.0
service-identity==18.1.0
six==1.15.0
Telethon==1.16.4
toolz==0.11.1
tornado==6.0.4
Twisted==20.3.0
txaio==20.4.1
typing-extensions==3.7.4.2
tzlocal==2.1
urllib3==1.25.10
varint==1.0.2
web3==5.15.0
websockets==8.1
yarl==1.1.0
zope.interface==5.1.0

What was wrong?

Hello, i'm trying web3.py to my new project. When i try to send a transaction with the example of the doc i got an error.

There error :

    nonce=w3.eth.getTransactionCount(w3.eth.coinbase),
  File "/mnt/c/Projects/arbitrage/venv/lib/python3.8/site-packages/web3/eth.py", line 144, in coinbase
    return self.get_coinbase()
  File "/mnt/c/Projects/arbitrage/venv/lib/python3.8/site-packages/web3/module.py", line 58, in caller
    result = w3.manager.request_blocking(method_str, params, error_formatters)
  File "/mnt/c/Projects/arbitrage/venv/lib/python3.8/site-packages/web3/manager.py", line 158, in request_blocking
    raise ValueError(response["error"])
ValueError: {'code': -32601, 'message': 'The method eth_coinbase does not exist/is not available'}

Please include any of the following that are applicable:

Here my code :

   w3 = Web3(Web3.HTTPProvider('https://mainnet.infura.io/v3/PROJECTID'))
    print(w3.eth.get_block('latest'))
    signed_txn = w3.eth.account.signTransaction(dict(
        nonce=w3.eth.getTransactionCount(w3.eth.coinbase),
        gasPrice=w3.eth.gasPrice,
        gas=100000,
        to='0xa71ac2c62A1b477186f5CbF45d94fFcd5D7e5711',
        value=0.005,
        data=b'',
    ),
        'MYKEY',
    )
    print(w3.eth.sendRawTransaction(signed_txn.rawTransaction))

I'm using infura as node.

wolovim commented 3 years ago

Hey @mapapuche, that example in the docs is a bit confusing. Instead of w3.eth.coinbase, just enter the address of the account you want to send the transaction from. I'll clarify the docs then close this issue. Let me know if you have any follow-up questions.

wolovim commented 3 years ago

If that is the entirety of your code, it looks like you have some conceptual gaps to fill in. I wrote a guide here for getting started with Ethereum and Web3.py: https://snakecharmers.ethereum.org/a-developers-guide-to-ethereum-pt-1/.

mapapuche commented 3 years ago

Ok thank you. will read it now

mapapuche commented 3 years ago

PS : just notice a fun fact, my name is Valentin Garreau ;)

wolovim commented 3 years ago

Wild. Hello long lost cousin 😄

This issue will be closed once the docs change PR gets merged in, but you're still welcome to ask questions. Feel free to open a new issue if its something totally unrelated.

mapapuche commented 3 years ago

Your guide is nice. Now i have the buy token working well, i'm asking myself new question lol. Did you have a guide about how to sell token ? In the guide at the end of part 2 you start to talk about it but there is no example about how to sell token to get back eth

wolovim commented 3 years ago

Thanks @mapapuche. My next blog post will explore contracts, including tokens, but it's still in development. I don't have another resource in mind, but ethereum.org has a lot of great tutorials and other resources. Maybe that's a good place to explore next: https://ethereum.org/en/developers/tutorials/.