0

I am trying to figure out what counts as an external function call.

Let's say Contract X calls function A in a third-party non-related Contract B and then that function turns around and calls function B in its own (Contract X) contract...is that considered an external function call because it originated from outside or is it considered an internal function call because it called a function within itself?

For some extra context, I am looking at this function...it is called by a third party but then calls a bunch of functions in itself. It uses try/catch which is supposed to only be for external function calls and contract creation

function performUpkeep() public nonReentrant
        {
        // Perform the multiple steps of performUpkeep()
        try this.step1() {}
        catch (bytes memory error) { emit UpkeepError("Step 1", error); }

        try this.step2(msg.sender) {}
        catch (bytes memory error) { emit UpkeepError("Step 2", error); }

        try this.step3() {}
        catch (bytes memory error) { emit UpkeepError("Step 3", error); }

        try this.step4() {}
        catch (bytes memory error) { emit UpkeepError("Step 4", error); }

        try this.step5() {}
        catch (bytes memory error) { emit UpkeepError("Step 5", error); }

        try this.step6() {}
        catch (bytes memory error) { emit UpkeepError("Step 6", error); }

        try this.step7() {}
        catch (bytes memory error) { emit UpkeepError("Step 7", error); }

        try this.step8() {}
        catch (bytes memory error) { emit UpkeepError("Step 8", error); }

        try this.step9() {}
        catch (bytes memory error) { emit UpkeepError("Step 9", error); }

        try this.step10() {}
        catch (bytes memory error) { emit UpkeepError("Step 10", error); }

        try this.step11() {}
        catch (bytes memory error) { emit UpkeepError("Step 11", error); }
        }

1 Answer 1

1

The syntax makes those external. by doing this.yourFunction() instead of simply yourFunction(), you're effectively making an external call to yourself (it's a CALL opcode, not a JUMP or a JUMPI, you can call public or external function that way, but not internal ones, msg.sender and msg.value are updated and you can do try{...} catch).

Note that there must be a reason why this is done like that, if your issue is just that you need to test if a function succeeded it's always gonna be cheaper to create logic yourself to handle that than making external calls, so there must be something else than just "the dev needed a way to catch errors".

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.