Skip to Content
Ethereum Cookbook
book

Ethereum Cookbook

by Manoj P R
August 2018
Intermediate to advanced
404 pages
11h 19m
English
Packt Publishing
Content preview from Ethereum Cookbook

There's more…

The approve method in ERC20 is susceptible to the Transaction Ordering Dependence (TOD) attack. A malicious spender can wait for the approver to change the allowance from x to y and include a transaction to spend x tokens. If the spender's transaction will be executed before the approver's transaction, then the spender will successfully transfer x tokens and will gain the ability to transfer another y tokens.

One possible solution to resolve this condition is to first reduce the spender's allowance to 0 and set the desired value afterwards. The recent standards also include increase and decrease approval methods to safely change the approval limit. These functions avoid the need to call the approve function twice and wait until ...

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

Building Ethereum Dapps

Building Ethereum Dapps

Roberto Infante
Ethereum For Dummies

Ethereum For Dummies

Michael G. Solomon

Publisher Resources

ISBN: 9781789133998Supplemental Content