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
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.'
(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.