How to hide a function of all but visible to the owner. For example there is a function:
function freezeAccount(address target, bool freeze)
How to hide it from others.
How to hide a function of all but visible to the owner. For example there is a function:
function freezeAccount(address target, bool freeze)
How to hide it from others.
There are some visibility specifiers in Solidity, but none of them allows to "hide function from others".
Everything that is inside a contract is visible to all external observers. Making something private only prevents other contracts from accessing and modifying the information, but it will still be visible to the whole world outside of the blockchain.
So, you can't hide function, but you can restrict access.
This is usually done with function modifiers:
pragma solidity ^0.4.0;
import "github.com/ethereum/solidity/std/owned.sol";
contract Test is owned {
function freezeAccount(address target, bool freeze) onlyowner {
// ...
}
}
onlyowner
function modifier is defined in solidity's standard library.
For more information see Restricting Access section in Solidity docs.