3

I am trying to call a contract function deployed in Ganache. I am pretty sure the contract is deployed because I can transact() and work with other functions. But when I call() it, I get this error:

Could not transact with/call contract function, is contract deployed correctly and chain synced?

this is my function call:

 updated_card = magic_ideas.functions.get_card('731759').call()

Previously, I have to "deploy an exam" with this code and it works correctly:

 t_hash1 = magic_ideas.functions.new_card('title', 'example_text', 'www.card.com', '731759').transact()

I get a t_hash1. Then when I try to get_card using .call() I get the error. What am I missing?

EDIT

This is the contract declaration:

magic_ideas = w3.eth.contract(address="0x246eCb1dA50199FD7FcC20Ad08C617C52e34b128", abi=abi)

The abi is a copy & paste from remix.

5
  • 1
    I am also having the same issue. – Njabulo Mar 2 '20 at 10:47
  • 1
    Would help to answer your question if one would know the full source code needed to understand the problem and then the error message 🙌 – Mikko Ohtamaa Aug 15 '20 at 9:50
  • @MikkoOhtamaa What part of the code do you think is missing? the connection is pretty straightforward ` w3 = Web3(Web3.HTTPProvider('127.0.0.1:7545'))` . I'll add the contract declaration, if I need to add something else, let me know and I'll add it. – Alejandro Veintimilla Aug 15 '20 at 16:45
  • 3
    Suggest replicating the problem in a small code base so you can post the complete source code and people can get to the bottom of it. – Rob Hitchens Aug 16 '20 at 2:04
  • 2
    Please post a compelte source code for a repeatable problem, so we do not need to guess what goes to variables and such. Then we can help you. – Mikko Ohtamaa Aug 16 '20 at 20:42
1

use:

updated_card = magic_ideas.functions.get_card('731759').transact()

instead of

updated_card = magic_ideas.functions.get_card('731759').call()

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.