TransWikia.com

Migrate contract from testnet to mainnet

Ethereum Asked on December 20, 2021

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

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

Answered by Giuseppe Bertone on December 20, 2021

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

https://www.trufflesuite.com/docs/truffle/reference/configuration#networks

Answered by abcoathup on December 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP