I'm still learning to develop dApp and currently, I conduct some testing on my dApp.

I found out that someone who is part of the blockchain network (miner and node) can replace our deployed smart contract using Truffle

truffle migrate --reset --network networkName

I want to make sure that only the contract owner can replace the current smart contract. How can I do that?

  1. The only way for some to replace your contract is if they have the private key of the account with which you have deployed that contract, as well as the nonce used upon deployment.
  2. Truffle is typically used for conducting tests on a private network that you set up on your local machine. If you terminate that network and then create it again from scratch (for example, via truffle migrate --reset), then you will obviously be redeploying your contract, but the old contract would be meaningless at the point, since the network in which it was deployed is no longer viable.
  • So anyone can redeploy my contract if use truffle? – Iwan Mar 24 '20 at 10:21
  • @Iwan: Anyone who can connect to the same network AND who has the private key of the account with which you have deployed that contract, as well as the nonce used upon deploying it. And like I said, Truffle is used for testing on a local private network, so I have no idea why you are even bothered about this issue to begin with. – goodvibration Mar 24 '20 at 10:26
  • @Iwan: I have a feeling that you don't quite understand the meaning of redeploying a contract (i.e., redeploying it at the exact same address), and that you don't quite understand the difference between a contract and deployed instances of that contract (yes, there can be several). – goodvibration Mar 24 '20 at 10:26
  • Yeah, you're right I'm pretty new on this topic and platform. Can I set up some authorization for deploying a contract on truffle? – Iwan Mar 24 '20 at 12:23
  • You don't need any authorization when using Truffle; it does it all for you. – goodvibration Mar 24 '20 at 12:25

Where did you found out this? Would you mind to share the details?

The information is completely wrong.

  • I try to redeploy my contract using another account via Truffle and it works my old contract replaced. – Iwan Mar 24 '20 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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