What is the safest way to migrate a contracted deployed in a testnet (Rinkeby) to mainnet? I can change the configuration of my truffle project and read the code from my git repository, but is there a better way to migrate? For example, without coming back to my off-chain repo?

2 Answers 2


To deploy a smart contract you send a transaction where the recipient is set to null and the payload composed by contract's bytecode plus some code to deploy the contract itself.

This means that, if you want to deploy exactly the same smart contract with exactly the same init parameters, and you don't want to go back to your original offchain code or repo, you can simply copy & paste the payload of already sent transaction and send a new transaction to another network, even the Mainnet, with a wallet at your choice that support deploying smart contracts (i.e. MyCrypto).

Look at this example:

  • First I created a smart contract on Goerli with remix and MetaMask
  • Then I copied the payload from Etherscan (input data)
  • Then I used MyCrypto deploy contract to send the same payload to Rinkeby
  • The result is exactly the same contract

I would suggest that you first deploy and test on Ropsten testnet as it is uses Proof of Work consensus as does mainnet, and is the testnet most like mainnet.

If you deployed your contract to testnet(s) using truffle, then once you have tested appropriately, you should use the same process with truffle to deploy your contract to mainnet.

See the truffle documentation for how to configure to deploy to different networks.

truffle migrate --network live


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.