If we consider this code below

pragma solidity 0.8.0;
interface testInterface{
   function externalFunction(uint _test) external returns(bool);

contract abc{
    uint public var1;

    function testTryCatch() public {
        var1 = 22;
        try testInterface(address(0)).externalFunction(var1) {} catch {}

it is sure function call will fail on try line , when call will finish value of var1 will be 22 or 0 ? if 0 then what is use of try catch and differences from other language if 22 then is it not violating the concept of blockchain ?

1 Answer 1


I did a test run to check the effect and transaction failed (hence no value updated in storage) even with try catch block

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.