1

I'm new to Solidity and see:

function transferFrom(address from, address to, uint256 value)
    onlyOwner
    returns (bool)
{
  return super.transferFrom(from, to, value);
}

I mean is "from" here the contract address? Or can this be called by the owner to transfer from some address (given password) to any other address? Thank you!

1 Answer 1

1

Here's the basic flow for ERC-20. Assume Alice, Bob, Charlie.

  1. Bob calls approve(Alice, 10).
  2. Now Alice can call transferFrom(Bob, Charlie, 10).

Without Bob's approval, Alice's call to transferFrom will error out: she can't send Bob's tokens without his approval.

If Alice wanted to send to Charlie, she would instead call transfer(Charlie, 10) but that would send Alice's tokens.

from and to are any address (it can be a contract, but doesn't have to be).

3
  • More clear now, but does this need onlyOwner modifier? Shouldn't this be only on "approve" function, assuming Bob is the owner?
    – kpopguy
    Commented Oct 22, 2018 at 7:29
  • Oh wait, so it doesn't matter as approve is always the msg.sender? Like: anyone who calls it gives permission of 3rd party to take some tokens from said sender? So onlyowner here is useless I guess.
    – kpopguy
    Commented Oct 22, 2018 at 7:34
  • Yes, approve typically always uses msg.sender. Yes, tokens usually don't have onlyOwner.
    – eth
    Commented Oct 22, 2018 at 9:18

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.