Call to the unknown
DoS attacks are very common in Ethereum when a contract interacts with other addresses. These addresses can be either externally owned addresses or contracts. Performing validations based on these conditions can be very dangerous.
In this recipe, you will learn the pitfalls of interacting with other address and ways to avoid them. You will also learn about a design pattern that can help mitigate these issues, up to a certain point.
Getting ready
It's expected that you have a basic understanding of the Ethereum blockchain and solidity before stepping through this recipe.
The Remix IDE (https://remix.ethereum.org) can help you quickly test and deploy the contract. Also, you can use any Ethereum client (geth
, parity
, and so on) and the solc
compiler to run this contract.
How to do it...
- There are multiple ways a contract can interact with other contracts. Making validations around these interactions cannot be trusted, and the destination contract can manipulate them:
require(<...