I want to get the return data written in solidity function in web3js .
I am using the web3.min.js
from the truffle pet-shop package as the web3 library . Everything is working fine when calling the function it is returning the transaction data from which I used web3.eth.getTransactionReciept
to get the details and the gas is also used. Now I want the data which is returning
my solidity method
function helloworld() public returns (string) {
return "helloworld";
}
The js part
<script>
if (typeof web3 !== 'undefined') {
web3 = new Web3(web3.currentProvider);
} else {
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:7545"));
}
web3.eth.defaultAccount = web3.eth.accounts[0];
console.log('web3.eth.accounts :', web3.eth.accounts);
var walletContractJSONabiGlobal;
$.getJSON('./contracts/Wallet.json',async function(walletContractJSONabi) {
walletContractJSONabiGlobal = walletContractJSONabi;
var walletContract = web3.eth.contract(walletContractJSONabi.abi);
var walletInstance = walletContract.at('0xc74c8d941494495a4f65c42bebc556398e1f028d');
walletInstance.helloworld((err,data)=>{
if (err) {
console.log('err :', err);
} else {
console.log('data :', data);
}
})
})
</script>
I getting the data in console
data : 0x988d4bd3169a4d752f6e4ac230d01840f2f7b4cc8e87d768a8e41b6fe867740d
I did the web3.toAscii(this transaction is)
but it is not coming proper result which is expected as this is not a hex value
When output of web3.eth.getTransactionReciept
blockHash : "0x552a93b0035571b93e4a1a89daa445663b0ddb29974078cdf9a250b7f873ca96" blockNumber : 10 contractAddress : null cumulativeGasUsed : 21899 gasUsed : 21899 logs : [] logsBloom : "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" status : "0x01" transactionHash : "0x988d4bd3169a4d752f6e4ac230d01840f2f7b4cc8e87d768a8e41b6fe867740d" transactionIndex : 0
Please Help in this Thank YOu