1

Im trying to send a transaction to contract function with web3.py on ropsten testnet. while doing so, Im getting this error.

AttributeError: 'list' object has no attribute 'buildTransaction'

here is my web3.py transaction signing code

tx = contract_instance.greet("Hi devs").buildTransaction({'nonce': web3.eth.getTransactionCount(account_address)})
# Get tx receipt to get contract address
signed_tx = web3.eth.account.signTransaction(tx, key)
tx_receipt = w3.eth.getTransactionReceipt(tx_hash)
web3.eth.sendRawTransaction(signed_tx.rawTransaction)

please let me know what seems to be the problem. full code here https://i.stack.imgur.com/3hMUP.jpg

  • Well, you could by the least indicate which line of code throws this exception (we're not supposed to guess that). In addition, we have no way of (yet again) guessing the values of some of the variables in your code, for example, account_address, key and tx_hash. Please spend some time rewriting your question properly, including all the required information! – goodvibration Apr 30 at 16:28
  • What version of web3.py are you using? I suspect you're mixing syntax from different versions. The error indicates that contract_instance.greet(...) is returning a list. In the latest version of web3.py, you would use something like contract_instance.functions.greet(...).buildTransaction(...). (Note the .functions.) – smarx Apr 30 at 16:34
  • Oh, looking at your full code in the screenshot, ConciseContract may be the issue. Use the default factory instead and then use contract_instance.functions.greet(...).buildTransaction(...). And in the future, please post your full code directly rather than as a screenshot. Images are not searchable/copy-pastable/accessible. – smarx Apr 30 at 16:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.