December 2018
Intermediate to advanced
222 pages
6h 6m
English
As we discussed earlier, solidity has some low-level call methods: address.call(), address.callcode(), address.delegatecall(), and address.send(). These methods only return false when the call encounters an exception. So handling errors in external calls is very important in contracts, as shown in the following code snippet:
// goodif(!contractAddress.send(100)) { // handle error}contractAddress.send(20);//don't do thiscontractAddress.call.value(55)(); // this is doubly dangerous, as it will forward all remaining gas and doesn't check for resultcontractAddress.call.value(50)(bytes4(sha3("withdraw()"))); // if withdraw throws an exception, the raw call() will only return false and transaction will NOT be reverted ...Read now
Unlock full access