Created
April 16, 2018 12:35
-
-
Save axic/f727ad7c9ddecbe454213ce11da13871 to your computer and use it in GitHub Desktop.
Check if a Solidity contract function is running as part of a constuctor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* This is a helper to check if a Solidity contract function is running as part of a constructor. | |
*/ | |
library ContractHelper { | |
function runningInConstructor() internal view returns (bool ret) { | |
assembly { | |
ret := iszero(iszero(extcodesize(address))) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment