August 2019
Intermediate to advanced
486 pages
13h 52m
English
An account (address/contract) can call the approve function to approve the transfer of a certain amount to another account (address/contract).
Let's understand this using an example—Alice has 5,000 TokenX (symbol: TKX) in her Ethereum wallet account. Alice would like to allow her friend, Bob, to spend 1,000 TKX tokens, which Alice has approved for Bob's account. Once the tokens are approved, Bob can take 1,000 TKX or fewer tokens any time from Alice's account and transfer 250 to his friend, Charlie. To perform this operation, Bob will call the transferFrom() function, for example, transferFrom(Alice, Charlie, 250), to deduct 250 TKX from Alice and credit these to Charlie's account. After this transaction, Bob is now allowed ...