Use the checks-effects-interactions pattern

You should always exercise extreme caution when transacting with other external contracts as it may introduce several unexpected risks or errors. External calls should be treated as untrusted as they may execute malicious code. These kinds of calls should be considered as potential security risks and avoided if possible. The following is an example of a DAO reentrancy attack:

In the preceding code snippet, line 19 is an external call that allows Hacker's fallback function at line 38 to repeatedly withdraw the Escrow funds from the Escrow account until all the funds in the Escrow account are drawn. ...

Get Learn Ethereum now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.