Should it not be such that as soon as I send the ether to any DAO, I will immediately receive the tokens ? So what is the use of approve here ?


Say I own the keys to account A. And you own the keys to account B.

I have 100 tokens in account A, and I want to transfer it to you.

I can execute a transfer(...) from account A to B.

Or I can approve(...) the transfer off 100 tokens from A to B.

And you can later call transferFrom(...) to transfer up to 100 tokens from A to B.

See the section "Withdrawal Process Explanation" in How do I convert my The DAO tokens into ethers using the withdrawal contract after the hard fork? for a working example of the approve(...) function.

| improve this answer | |
  • 1
    So when transfer() is called, it immediately sends the ether from A to B while approve() is more like "B has the permission to access 100 ether from A from now on". And account B can withdraw this approved 100 ether anytime in future with a single or multiple withdrawl. Did I get it right? – freerunner Jul 30 '16 at 23:56
  • Yup. You've got it right. And you can have multiple transferFrom(...) up to a total of 100 tokens. – The Officious BokkyPooBah Jul 30 '16 at 23:57

When one sends ether to a DAO (during its creation period), one gets DAO tokens. That account that sent the ether (and only that account) may then later 'transfer' those tokens to another account. If you wish, however, to allow someone else to transfer your tokens, you (the original account holder) must first 'approve' that other account. The other account would then use 'transferFrom.'

Two notes:

(1) If you send ether to a DAO after it's creation period (plus grace period), the DAO will simply keep your ether and you will get no DAO tokens. "The DAO" creation period has long since passed.

(2) The most frequent use of 'approve' and 'transferFrom' that I've seen has been from exchanges such as kraken. When you sell tokens on kraken, they first call 'approve' for your account to approve themselves, and then they call 'transferFrom' to effectuate the transfer.

| improve this answer | |

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.