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()};
}
internal. – Xavier Leprêtre B9lab Sep 05 '16 at 10:33internalseems to be the best way to limit contract functions as intended above. Reference. – CBobRobison Sep 06 '16 at 16:53