Skip to Content
Mastering Blockchain Programming with Solidity
book

Mastering Blockchain Programming with Solidity

by Jitendra Chittoda
August 2019
Intermediate to advanced
486 pages
13h 52m
English
Packt Publishing
Content preview from Mastering Blockchain Programming with Solidity

The approve function

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

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Mastering Ethereum

Mastering Ethereum

Andreas M. Antonopoulos, Gavin Wood
Complete Cryptocurrency and Blockchain Course | Learn Solidity

Complete Cryptocurrency and Blockchain Course | Learn Solidity

Ravinder Deol, Codestars By Rob Percival, Thomas Wiesner

Publisher Resources

ISBN: 9781839218262Supplemental Content