Using external contract

Dear
How can we see the external function result in this contract ? We are in the same contract. We couldnt call the external function . What do you think ?
‘’’

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.10;

contract Base {

   

    function privateFunc() private pure returns (string memory) {

        return "private function called";

    }

    function testPrivateFunc() public pure returns (string memory) {

        return privateFunc();

    }

   

    function internalFunc() internal pure returns (string memory) {

        return "internal function called";

    }

    function testInternalFunc() public pure virtual returns (string memory) {

        return internalFunc();

    }

   

    function publicFunc() public pure returns (string memory) {

        return "public function called";

    }

   

    function externalFunc() external pure returns (string memory) {

        return "external function called";

    }

}

‘’’

1 Like

is this a question on the function visibility (for lack of a beter word) in solidiyt. public functions can be called from any contract by anyone. External functions “should” only be called from a different smart contract and not from withtin the smart contract its decalred in. For example say i have some contract A, and another contractB. In the file where your using contract B say you import contract A so that you can use its functions inside contractB. External functions mean that they should only be called by another contract. They are handly because they cost less gas to execute than public. However you can still call external functions from within the contract the function was declared in

Internal functions can only be called within the scope of the contract it was declared in. This means you can call an internal function in one, the contract it belongs to and also any inheriting contarcts.

Private functions can only be called in the function they are declared in.

Could you explain a little more exaclty what your question it. from that post im presuming its to do with function scopes in solidity

1 Like

I changed my question. Could you deploy in remix ?
We can see result of the following function but we are in same contract and this is external function

function externalFunc() external pure returns (string memory) {

return "external function called";

}

6666

If external function is not reachable from inside the same contract , how could we see external functions results in same contract ?

1 Like

the eternal mfunction is reachable inside the same smart contract. its just bad practice to mark a function as external and call it from within the same contract. the only reason we use external is to optimize gas whenver we have a case where we have a function that we know will only ever get called externall from another contract. i can deploy it yes but you should know this is the reason