I have a transaction in contract which "requires" only owner can call. In front end when I call this with accounts other than owner of the contract I want to display an error. Code below doesn't work. It says
:Uncaught (in promise) Error: Invalid JSON RPC response: {"id":6,"jsonrpc":"2.0"}
this.state.web3.eth.getAccounts((error, accounts) => {
TalioInterview.deployed().then((instance) => {
try {
return instance.isTalioOwner.call({from:accounts[1]})
}catch(err){
alert("You are not authorized to run this.");
}
My contract looks as below
function isTalioOwner()
public onlyIfTalioOwner()
constant
returns(bool)
{
return true;
}
Found a similar question here, but without any answer. What is the best solution here other than changing contract to return false for non-owner accounts ?