How can you program a contract so certain functions can only be called by other functions within the contract? Would you use a modifier? In the example below I'd want a user to have to call metaAwesomeness()
to access awesomeness()
, which would otherwise be inaccessible via superDuperOnly()
:
contract superDuper {
modifier superDuperOnly() {if (msg.sender != address(this)) throw; _};
function awesomeness() superDuperOnly {};
function metaAwesomeness() {awesomeness()};
}
Taking it one step further, I'd also be interested to use this modifier on another contract, so only superDuper
functions can call kindaCool
's nifty()
:
import "./superDuper.sol";
contract kindaCool {
function nifty() superDuperOnly {};
}
EDIT: for solution (Pt 1):
The first contract, superDuper
, would look like:
contract superDuper {
function awesomeness() internal {};
function metaAwesomeness() {awesomeness()};
}