A value returned by a function in the smart contract cannot be captured as every function returns a hash.
Then, why write return statements in Solidity function?
For example,
event LogNewVoter(address sender, string name, bool isSuccess);
function addVoter(address _voter,string _name, bytes _voterImageHash) payable public returns(bool) {
require(msg.sender == votingAdmin);
Voter storage sender = voters[_voter];
if(sender.isVoter){
revert("This address is all ready registered as a voter!");
//throw;
}
voters[_voter].name = _name;
voters[_voter].hasVoted = false;
voters[_voter].isVoter = true;
voters[_voter].voterImageHash = _voterImageHash;
LogNewVoter(msg.sender,_name,true);
return true;
}
In above question, I can get whether the voter is registered successfully or not by using events. If I can not capture value returned by a function then why to write return statements in function?