AddressUtils.sol 605 B

123456789101112131415161718192021
  1. pragma solidity ^0.4.18;
  2. /**
  3. * Utility library of inline functions on addresses
  4. */
  5. library AddressUtils {
  6. /**
  7. * Returns whether there is code in the target address
  8. * @dev This function will return false if invoked during the constructor of a contract,
  9. * as the code is not actually created until after the constructor finishes.
  10. * @param addr address address to check
  11. * @return whether there is code in the target address
  12. */
  13. function isContract(address addr) internal view returns (bool) {
  14. uint256 size;
  15. assembly { size := extcodesize(addr) }
  16. return size > 0;
  17. }
  18. }