In https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol
the function detecting contract
function isContract(address account) internal view returns (bool) {
// According to EIP-1052, 0x0 is the value returned for not-yet created accounts
// and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
// for accounts without code, i.e. `keccak256('')`
bytes32 codehash;
bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
// solhint-disable-next-line no-inline-assembly
assembly { codehash := extcodehash(account) }
return (codehash != accountHash && codehash != 0x0);
}
The comment says that there is a distinction between not-yet created accounts and account without code. I don't understand it, I thought all the possible accounts are already technically created just their balance and code are 0, resp. empty in the beginning.
extcodehash
. It could be a new feature, added in solc 0.6.x. – goodvibration May 12 '20 at 13:39