Smart Contract Deployment – Deploying to Same Address on Mainnet and Ropsten

contract-deploymentnoncereplay-attackropstentestnets

Traditionally when people have deployed contracts for public use they have tended to publish separate contract addresses for Testnet and Mainnet. Often this then requires them to include code to check which network the contract is on, as we see in this example .

This seems to have been necessary previously because in the absence of replay protection, Morden used a very high accountStartNonce, making it impractical to create the same address on Mainnet. (See
Is it possible to give a contract the same address from morden )

Now that EIP 155 replay protection is live and Ropsten is using an accountStartNonce of 0 like Mainnet, are there any good reasons left to carry on using separate addresses for mainnet and testnet, or should we get rid of this code and just use a single address for both?

Best Answer

A rather weak argument against your suggestion is the following: The deployer would have to use the same private key in both test and main net. This could be considered a security risk, as private keys in test net usually do not have to be stored and handled securely, while in main net they most definitely do. Mixing the two domains would, thus, blur the security requirements of each of them.

I would argue, though, that the pros of having the same address in both test and main net are not very convincing either. In the example you linked a better solution would, in my opinion, be passing the respective address in the constructor.

Also, not all net-specific code would be made obsolete anyway (e.g., parameters such as crowd sale durations, validator numbers, ...).