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.
Ethereum Stack Exchange is a question and answer site for users of Ethereum, the decentralized application platform and smart contract enabled blockchain. It only takes a minute to sign up.Sign up to join this community
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
AmIOnTheFork contracts as an oracle to determine which blockchain you are running on.
And sample code to use the above contracts are in the