My contract uses onlyOwner to restrict access to several functions. Everything was working but I've had to port everything to use Infura and no longer have local accounts.

I'm able to sign transactions offline / use sendRawTransaction but I'm not sure how to go about doing this with pure functions (not creating transactions) that are still onlyOwner.

I'm using web3.py but I can figure it out from web3.js etc.


You don't need to sign a call at all. Just specify the right from address to make it past the onlyOwner check.

If you're having trouble doing that, please share your code.

  • Doesn't that defeat the purpose of onlyOwner if I can specify the from: address without any authentication? – heyyouyayou Jan 22 '18 at 21:55
  • calls can't have any side effects, so there's no reason to authenticate. – user19510 Jan 22 '18 at 21:56
  • 2
    I guess @heyyouyayou is trying to limit access to read data. However, that is not so simple in Ethereum. All data is visible on the blockchain. The transaction that would have written the information is visible and can be inspected with any blockchain explorer, so the value cannot be secret unless explicitly encrypted. (Even hiding it with encryption may not be simple. Anyone with access permissions would need to have the key and other information needed to decrypt.) – Ajoy Bhatia Jan 22 '18 at 23:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.