0

I have a contract(A) function with the standard onlyOwner access. If I call directly from the deployed account the function works fine. But when I import this contract(A) into another contract(B) and I call that function with the onlyOwner modifier. Report me the error.

It´s seems that the msg.sender that arrive to the modifier contract(A) is the the deployed address of the contract(B) and not the default account selected and deployed from Remix.

My doubt is how can I wrapp the msg.sender to take that that I select in Remix??

This is my idea, but any other idea is wellcome.

Thx

UnexpectedCharacter
  • 852
  • 1
  • 11
  • 30

1 Answers1

1

I am not taking into account the security issues this could cause here but instead of using msg.sender which would equal the contract that calls upon the other contract use tx.origin which would use the address of the person which started the transaction.

Gabe
  • 363
  • 1
  • 11
  • Nice but, I call a external function like this: tokensContract.balanceOf(userAddress) I don´t how to pass the tx.origin, It´s seems that the EVM get the address automaticly. How can I do?? – UnexpectedCharacter Feb 13 '19 at 11:48
  • 2
    @UnexpectedCharacter: DON'T USE tx.origin! (see https://ethereum.stackexchange.com/a/200/16043). – goodvibration Feb 13 '19 at 12:35
  • 1
    Like I said I'm not taking any security or other issues that can happen with using tx.origin into account. Just saying that this will solve his current issue. – Gabe Feb 13 '19 at 13:03
  • The problem is that I don´t follow the ERC-20 standard and I add the modifier when it was not necesssary. Otherwhise thankyou for the help guys !! – UnexpectedCharacter Feb 13 '19 at 15:37
  • Hi @goodvibration Please consider adjusting your last comment, otherwise it is flagged and may be deleted by a moderator as it doesn't meet the spirit of the community. Thank you. – eth Feb 15 '19 at 08:42