0

I have got following SC:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.7;
//https://www.zupzup.org/smart-contract-interaction/
import "contracts/CalleeVer8.sol";
contract Caller {
    function someAction(address addr) public returns(uint) {
        Callee c = Callee(addr);
        return c.getValue(100);
    }
    
    function storeAction(address addr) public returns(uint) {
        Callee c = Callee(addr);
        c.storeValue(100);
        return c.getValues();
    }
    
   function someUnsafeAction(address addr) public {
         (bool  result,)=addr.call{value: 10, gas: 5000}( abi.encodeWithSignature("storeValue(uint256)", 100) );
          if(result==false) {
             //Call result processing
          }
         
    }
}

Please guide me what is the difference between: (1) (bool result,)=addr.call{value: 10, gas: 5000}( abi.encodeWithSignature("storeValue(uint256)", 100) ); And (2) (bool result,)=addr.call(abi.encodeWithSignature("storeValue(uint256)", 100) ); ?

In case of (1), why I am not getting the error if the Calleee contract shown below does not have fallback () or receiver() function:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.3;

contract Callee {
    uint[] public values;

    function getValue(uint initial) public returns(uint) {
        return initial + 150;
    }
    function storeValue(uint value) public {
        values.push(value);
    }
    function getValues() public returns(uint) {
        return values.length;
    }
}

Your Answer

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

Browse other questions tagged or ask your own question.