2

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.

2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.