This is an absolute newbie question. Given this simple Hello World contract:
pragma solidity ^0.4.4;
contract Greeter {
function Greeter() {}
function sayHello() returns(string) {
return "hello";
}
}
I deploy it and try to get the value from the sayHello()
function:
$ truffle compile
$ truffle deploy
$ Greeter.deployed().then(function(instance){ return instance.sayHello()}).then(function(result){console.log(result);});
I was expecting to see "hello" in the output of the above statement but this is what I actually get:
{ tx: '0xa4333e052b00fdf00d9ad944862b592d091cfb4ff68d610e297cb52cfbf5ebfd',
receipt:
{ transactionHash: '0xa4333e052b00fdf00d9ad944862b592d091cfb4ff68d610e297cb52cfbf5ebfd',
transactionIndex: 0,
blockHash: '0x40aca77673267ca149fe34a62c95b2869285d7819d21279d59fc0714c702314c',
blockNumber: 64,
gasUsed: 21867,
cumulativeGasUsed: 21867,
contractAddress: null,
logs: [] },
logs: [] }
undefined
That is to say, result is an object of this information instead of the "hello" string. Is there a way I can get the actual result of the function?