Sender of function

I have 2 contracts that have basically the following structure:

contract Data is Ownable
{
   function sellData()
   {
      require(msg.sender == owner());
   }
}

contract Usage is Ownable
{
   function sell()
   {
      require(msg.sender == owner());
      d.sellData();
   }
}

Both contracts have the same owner O1. I call the sell() function from Usage with the user O1 that owns both contracts. The requirement passes fine and then the sellData() function is called from the Data contract. However, this triggers an error in the require because the sender is not equal to the contract owner. I was hoping that the msg.sender of sellData() would be the same as that of sell() but apparently that’s not the case. Does anyone know how to solve this problem ? Can I pass the msg.sender to d.sellData() in some way in Solidity ?

No, msg.sender is fixed by the way the EVM works.

In this scenario Usage should be the owner of the Data contract for this to work.

1 Like

Thank you, Frangio. What you say makes perfect sense.