I am trying to call a method from a smart contract and I don't understand the response I am getting. I am running the following smart contract on a local blockchain using ganache-cli. I am then trying to call the testFunc method from the below javascript code. I am getting an object as a response that doesn't seem to have the return value of the method in it but does have details of the method.
Smart contract:
pragma solidity ^0.8.3;
contract HelloWorld {
function testFunc() pure public returns (string memory){
return "Hello World!";
}
}
Javascript code:
<script src="https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js"></script>
<script>
const web3 = new Web3("http://localhost:8545");
const contractAddress = "0x4E265652f963548b8A8e6452575B3009538b858f";
const abiArray = [{"inputs":[],"name":"testFunc","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"}];
var contract = new web3.eth.Contract(abiArray, contractAddress);
console.log(contract.methods.testFunc.call()); //I have also tried contract.methods.testFunc() which produced the same result
</script>
The response object I am getting looks like this: [![enter image description here][1]][1]
Is this the response I am supposed to get and if so how do I parse this to get the return value of the method?
[1]: https://i.stack.imgur.com/NIkpL.png