I am trying to write a smart contract for Crowdsale. What extra measures should one keep in mind during smart contract development to avoid replay attacks (after the hard fork of block 1,920,000)?

  • What contract are you writing and what's your concern?
    – eth
    Commented Aug 3, 2016 at 23:16
  • I have added in my question.
    – Aniket
    Commented Aug 10, 2016 at 6:32
  • It's probably still too broad but I'll reopen (you can also click "reopen" in the future). Remember, the better the question, the better the answers you'll probably get.
    – eth
    Commented Aug 10, 2016 at 9:08
  • Thanks. Actually i am new to this technology and i am working using testnet, so asking question is the only way to be fully prepared before going on livenet.
    – Aniket
    Commented Aug 10, 2016 at 10:18

1 Answer 1


When a user sends a transaction to your contract using Ethereum (ETH), if that user also has ETC in the same account in the Ethereum Classic Blockchain (ETC), then that transaction could be replayed in the Ethereum Classic Blockchain (ETC) with unexpected results.

To avoid this, you can upload your contract to both Blockchains with a modifier in your functions that throws an exception when it is executed in the Ethereum Classic Blockchain (ETC).


contract AmIOnTheFork {
    function forked() constant returns(bool);

    // Fork oracle to use
    AmIOnTheFork amIOnTheFork = AmIOnTheFork(0x2bd2326c993dfaef84f696526064ff22eba5b362);

    // Only allows execution in the forked chain (ETH)
    modifier only_eth_chain() {
        if (!amIOnTheFork.forked()) throw;

    function your_function()

This way, if your user wants to execute the your_function function, he will send a transaction in the Ethereum Blockchain (ETH). That transaction will be executed as usual, but if the transaction is replayed in the Ethereum Classic Blockchain (ETC), the transaction replayed will not be accepted and the ETC sent will be given back.

Your Answer

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

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