0

Im calling storage contract from logic contract, but when i change the owner to new logic contract,

Line 27 :         require(owner==msg.sender,"only owner can call");

This is not properly getting in the calling contract

// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "hardhat/console.sol";

contract Storagecontract{
    address public owner;
    
    constructor(address _owner){
     owner=_owner;
    }
   string public name="sreeshma";

   modifier  onlyOwner(){
    require(owner==msg.sender,"only owner can call");
    _;
   }

   function setOwner(address _owner)public {
    
    owner=_owner;

   }
    
    function set(string memory _name)public {
        console.log(owner,msg.sender);

        require(owner==msg.sender,"only owner can call");
        console.log(owner,msg.sender);
        name=_name;
    }
}


contract Logiccontract{

    function changename(address add, string memory name)public{
         (bool send,)=add.call(abi.encodeWithSignature("set(string)", name));
         console.log("status",send);

    }
     function changeOwner(address add, address _owner)public{
         (bool send,)=add.call(abi.encodeWithSignature("setOwner(address)", _owner));
    }

}


1 Answer 1

0

Using the low-level call function will not revert anything. You can only judge whether the execution is successful based on the result in the return value (result, data).

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.