I have a method in solidity and wants to return the sent string only for the owner address.
function greet(string str) returns(string) {
if (msg.sender == owner) {
return str;
} else {
return "Sorry I respond only to my owner";
}
}
In Rinkeby testnet, I am able to set the address directly without unlock or signing with private key web3.eth.defaultAccount = '0xC2107dFbCf6a70865f30fc439b1850bE434231c9';
and when i greet.call('Hello').... method I get the passed string returned perfectly and gets back 'Hello'
So my question is can anyone use my public address in web3.eth.defaultAccount and call the greet method ? I want only owner with private key can pass the test (msg.sender == owner). How can others without private key get through it ?