Is it possible for me to add code to my contract to check the blockchain it is running on?

This is for security reasons as I only want to be running on the official Ethereum blockchain.

1 Answer 1


See the conditional contracts listed in the question section of How to conditionally send ethers to another account post-hard-fork to protect yourself from replay attacks .

In particular, you can used the ClassicCheck or AmIOnTheFork contracts as an oracle to determine which blockchain you are running on.

And sample code to use the above contracts are in the SafeConditionalHFTransfer and ReplaySafeSplit contracts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.