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?
-
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???– goodvibrationCommented May 27, 2020 at 3:22
Add a comment
|
1 Answer
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..." 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.– NowsyMeCommented 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