Skip to content

Instantly share code, notes, and snippets.

@axic
Created April 16, 2018 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axic/f727ad7c9ddecbe454213ce11da13871 to your computer and use it in GitHub Desktop.
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 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