0

Solidity Code:

function getEvidence(string memory _evidenceID) view public returns (string memory) {
        require(evidenceOwner[_evidenceID] == msg.sender);
        string memory evidenceHash = evidenceIpfsHash[_evidenceID];
        return evidenceHash;
    }

Python Code:

@app.route('/getevi.html', methods=['GET', 'POST'])
def getevi():
    form = SignUpForm()
    if form.is_submitted():
        #web3.geth.personal.unlockAccount('0xe22858f99220ba98adc9be20558a75a323ec4749', 'redhat')
        evidenceID = request.form['eid']
        print(evidenceID)
        file_info = bcoc.functions.getEvidence(evidenceID).call()
        print(file_info)
        return render_template('getevi.html', file_info=file_info)  
    return render_template('getevi.html', form=form)

Output:

[2019-09-23 12:01:23,688] ERROR in app: Exception on /getevi.html [POST]
Traceback (most recent call last):
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/web3/contract.py", line 1354, in call_contract_function
    output_data = decode_abi(output_types, return_data)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/codec.py", line 179, in decode_abi
    return decoder(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_utils/functional.py", line 45, in inner
    return callback(fn(*args, **kwargs))
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 173, in decode
    yield decoder(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 142, in decode
    start_pos = decode_uint_256(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 127, in __call__
    return self.decode(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 198, in decode
    raw_data = self.read_data_from_stream(stream)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/eth_abi/decoding.py", line 308, in read_data_from_stream
    len(data),
eth_abi.exceptions.InsufficientDataBytes: Tried to read 32 bytes.  Only got 0 bytes

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "app.py", line 215, in getevi
    file_info = bcoc.functions.getEvidence(evidenceID).call()
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/web3/contract.py", line 842, in call
    **self.kwargs
  File "/home/mahir/test123/testDapp/microVenv/lib/python3.6/site-packages/web3/contract.py", line 1376, in call_contract_function
    raise BadFunctionCallOutput(msg) from e
web3.exceptions.BadFunctionCallOutput: Could not decode contract function call getEvidence return data b'' for output_types ['string']
127.0.0.1 - - [23/Sep/2019 12:01:23] "POST /getevi.html HTTP/1.1" 500 -
  • Do you still get an error if you comment out the require in your function? – user19510 Sep 23 at 6:58
  • yes... I am able to send a transaction into the network but i am unable to get it from the network... Is there any specific command to get string output? i have tried .call() method – Viraj Shah Sep 23 at 7:07
  • Then that code is probably not running at the address you're calling. Double check the address for bcoc and the network that you're connected to. Make sure it matches what you deployed. – user19510 Sep 23 at 7:25
  • I checked the address still its showing same error. Is there any alternative of calling .call() function which I can use? – Viraj Shah Sep 23 at 7:40
  • No, call() is correct. – user19510 Sep 23 at 7:55

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.