I'm trying to make a function that returns true if msg.sender is the owner.

This is my function;

function isAdmin() public view  returns (bool){
   require(admin == msg.sender);
    return true;

admin was given the value of msg.sender in the constructor.

Whenever I call this function it revert. From truffle or my app


x = await contract.deployed()

It revert!

My app;

await exchange.methods.isAdmin.call()

Also revert.

So what am I doing wrong?

1 Answer 1


Generally call will default to using 0x0000000000000000000000000000000000000000 as msg.sender, which is why this is reverting. That address is indeed not owner, so a revert is what you would expect. You can do call though and specific the msg.sender by doing await exchange.methods.isAdmin().call({from:addressYouWantToUse}) and replace the placeholder with the owner address

  • And how do I read the result from the response? i was expecting just true but i receive a lot back. An object. Oct 24, 2020 at 23:03
  • exchange.methods.isAdmin().call({from:addressYouWantToUse}) will return the value returned from the function Oct 25, 2020 at 1:25

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.