'internal' keyword in a function definition in Solidity

Does the internal keyword in a function definition such as:

function doSomeThing(uint _param) internal {...}


work similar to designating a method as private in other languages and thus makes the function only callable from within the contract?

The internal modifier can be better compared with protected in object-oriented programming languages. Internal functions of the contract C are visible to the code running at the current address (i.e. the current contract instance) but also to contracts derived from C.

Note that due to the architecture of the EVM, visibility is something that can be strictly enforced at the machine level: There is no way to call a function at another address unless it is explicitly available (i.e. you cannot just "cast" the contract to another type). It is also impossible to call internal or private functions of the same contract type at a different address.

• Well...there is no direct way to do those last things. But an elaborate deposit-challenge-verify mechanism could technically let you circumvent this restriction within another contract. After all, the function's publicly visible in the blockchain. – Jeff Coleman Jan 26 '16 at 8:30
• Yes, there are mechanisms to execute another contract's function (with EXTCODECOPY you do not even need an external service), but not in the context of the other contract. – chriseth Jan 27 '16 at 17:20

Yes. The internal modifer means that the function can only be called within the contract itself and any derived contracts.

private functions are not available in derived contracts.

From the docs:

internal:

Those functions and state variables can only be accessed internally (i.e. from within the current contract or contracts deriving from it), without using this.

private:

Private functions and state variables are only visible for the contract they are defined in and not in derived contracts.