Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 web3 method
installed web3 api and cannot get it recognized.
from web3 import Web3
nonce = web3.eth.getTransactionCount(acct1)
error = instance of 'Web3' has no 'eth' member
buran wrote Jun-04-2019, 03:35 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.

Please, post the entire traceback that you get. We need to see the whole thing. Do not just give us the last line.
Take a time to read What to include in a post
I guess your own file is named, right? Because otherwise you will get NameError. Note that you import Web3 (with capital W) from web3 (with lower w). Then in your code you use web3 (with lower w and it is not imported)
file name is

from web3 import Web3
#from solc import compile_source
#from web3.contract import ConciseContract
#from import Web3, EthereumTesterProvider

# code here
ganache_url = ""
web3 = Web3(Web3.HTTPProvider(ganache_url))

acct1 = "REMOVED"
acct2 = "REMOVED"

private_key = "REMOVED"

nonce = web3.eth.getTransactionCount(acct1)

tx = {
    'nonce': nonce,
    'to'   : acct2,
    'value': web3.toWei(1, 'ether'),
    'gas'  : 2000000,
    'gasPrice': web3/toWei('50', 'gwei')

signed_tx = web3.eth.account.signTransaction(tx, private_key)
tx_hash   = web3.eth.sendRawTransaction(signed_tx.sendRawTransaction)
I think the problem is you use web3 as variable name and it conflicts with the module name. use something different, e.g. w3.
That said, I am not sure when you want to use Web3 instance and when web3.eth. Docs is also bit confusing in this respect, e.g. Web3.eth redirects to wb3.eth

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  What is the use of call method and when to use it? everyday1 1 57 Jul-14-2019, 01:02 PM
Last Post: ichabod801
  Method not defined diskt 1 113 Jul-03-2019, 12:55 PM
Last Post: noisefloor
  Method not regocnized Lass86 3 182 Jun-19-2019, 09:03 AM
Last Post: Lass86
  [split] help with While method peterd1965 3 604 Jun-20-2018, 05:45 PM
Last Post: volcano63
  help with While method brawdhampshire 5 1,145 Jun-20-2018, 05:38 PM
Last Post: micseydel
  need method to look up dictionary key by value league55 3 568 Jan-17-2018, 10:58 PM
Last Post: metulburr
  Best Method for simple GUI? PythonAndArduino 4 1,056 Nov-17-2017, 06:22 AM
Last Post: heiner55

Forum Jump:

Users browsing this thread: 1 Guest(s)