1

When I try to interact with the contract with web3.py, I am using ganache, I get the completely useless error message:

ValueError: {'message': 'execution error: revert', 'code': -32000, ... , 'name': 'Error'}

It works correctly when using remix. This is my python code:

w3.eth.defaultAccount = w3.eth.accounts[0]
exams_contract = w3.eth.contract(abi=abi, bytecode=bytecode)
exams = w3.eth.contract(
    address=tx_receipt.contractAddress,
    abi=abi
)
tx_hash3 = exams.functions.studentAddExam(w3.eth.accounts[1]).transact()

And my solidity code:

function studentAddExam(address studentAddress) public returns (string memory returnString){
    // Receives a student's address and adds it to the people that passed that exam
    // Only the creator of the exam can do this
    string memory professorsExamHash = professorsExam[msg.sender];  // The hash of the exam owned by msg.sender
    Exam storage examObj = examHash[professorsExamHash];
    examObj.examSuccess[studentAddress] = true;
    return professorsExamHash;
}

I can interact with the contract using other functions.

1 Answer 1

1

Hope this helps someone. The error was in the ABI or in the Bytecode. I replaced it and it worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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