I was going through solidity documentation and found this paragraph inside "Function Types" section https://docs.soliditylang.org/en/v0.8.21/types.html#user-defined-value-types

A function of an internal type can be assigned to a variable of an internal function type regardless of where it is defined. This includes private, internal and public functions of both contracts and libraries as well as free functions. External function types, on the other hand, are only compatible with public and external contract functions.

What is a internal function type variable, does it even exists. And if not, what does this para mean?

2 Answers 2


Internal functions which accept function type as an argument can take internal, public and private functions when called. For example:

library L {
    function ops(
        uint256 _a,
        uint256 _b,
        function(uint256, uint256) pure returns (uint256) add
    ) internal pure returns(uint256 sum){
        sum = add(_a, _b);

contract C {
    using L for *;

    uint256 public sum;

    function calculate(uint256 _a, uint256 _b) external {
        (sum) = L.ops(_a, _b, add);

    // add can be internal, private or public but not external
    function add(uint256 _a, uint256 _b) internal/private/public pure returns(uint256){
        return _a + _b;

similarly for external functions accepting function type as an argument can take public and external functions when called. For example:

contract C1 {
    uint256 num;
    function foo(function(uint256) external returns(uint256) f) external {
        num = f(num);

contract C2 {
    uint256 num;
    C1 c;
    function foo() external {

    // bar can be external/public but not private/internal.
    function bar(uint256 _num) external/public returns(uint256){
        num = _num;
        return _num + num + 1;

Functions of type internal that can be accessed within the contract context and used as a class member or function reference (conditionally, since they are not real references). You can see examples here: https://ethereum.stackexchange.com/a/155184/99256

This is function: function ten_x(uint x) private pure returns (uint result)

Using it:

function rabbitHole(uint a) public returns (uint b);

function f1(uint a, function(uint) pure returns(uint) b) internal view returns(uint);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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