0

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

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 {
    }
}
  • Just to clarify: "if you can declare your interface as abstract contract..." – Lauri Peltonen Aug 6 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 Aug 6 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 Aug 6 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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