You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
958 B
27 lines
958 B
pragma solidity ^0.5.0;
|
|
|
|
/**
|
|
* @dev Collection of functions related to the address type,
|
|
*/
|
|
library Address {
|
|
/**
|
|
* @dev Returns true if `account` is a contract.
|
|
*
|
|
* This test is non-exhaustive, and there may be false-negatives: during the
|
|
* execution of a contract's constructor, its address will be reported as
|
|
* not containing a contract.
|
|
*
|
|
* > It is unsafe to assume that an address for which this function returns
|
|
* false is an externally-owned account (EOA) and not a contract.
|
|
*/
|
|
function isContract(address account) internal view returns (bool) {
|
|
// This method relies in extcodesize, which returns 0 for contracts in
|
|
// construction, since the code is only stored at the end of the
|
|
// constructor execution.
|
|
|
|
uint256 size;
|
|
// solhint-disable-next-line no-inline-assembly
|
|
assembly { size := extcodesize(account) }
|
|
return size > 0;
|
|
}
|
|
}
|
|
|