1

Is it possible to use externally declared interface functions internally in a smart contract?
i.e. say contract A inherits interface A, would contract A be able to implement the functions from interface A in an internal fashion (declaring a function as internal) not allowing the public to call it?

1
  • What's the point in declaring a function in the interface if no one except for other functions in the same contract can call it??? Commented May 27, 2020 at 3:22

1 Answer 1

2

An interface cannot contain functions declared as internal or public, only as external.

If you can declare your interface as contract and will not have that limitation.

contract Bob {
    function foo() internal;
}


contract Mar is Bob {

    function vote() public {
        foo();
    }

    function foo() internal {
    }
}
3
  • Just to clarify: "if you can declare your interface as abstract contract..." Commented Aug 6, 2019 at 5:48
  • it serves the same purpose in the end right? whether I declare as interface or abstract contract --> a layer of abstraction/compliance etc.
    – NowsyMe
    Commented Aug 6, 2019 at 7:37
  • You use interfaces in some situations, for example to write an EIP or you have to integrate two separate applications. You do not have to use it if you do not need it.
    – Ismael
    Commented Aug 6, 2019 at 14:51

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.