Say I have a contract with the address and method below.
myContract.at("0x9f8cedf1f93e46fac74cb9415db8bbec85f239b4").greet();
Can everyone who knows this address call this smart contract method? Any permissions restrictions?
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.
Sign up to join this communityIt depends how you write the contract.
You get the access control you design. There are more intricate access control patterns such as whitelists, but to lay out a simple example that is admittedly flawed, but hopefully illustrative:
contract Greeter {
address public owner;
function Greeter() public {
owner = msg.sender; // <= the "owner" will be set to the account that deployed it.
}
function greet() public view returns(string greeting) {
require(msg.sender == owner); // only the priviledged account will pass
return "Hello, owner.";
}
}
Hope it helps.
greeting
for the return string if it isn't used? I've seen this done before and I don't really understand the benefit of it.
Jun 8, 2018 at 1:53