Skip to main content
added 1 character in body
Source Link
Edmund Edgar
  • 16.9k
  • 1
  • 29
  • 58

I have a dapp consisting of two contracts, which don't particularly have a dependency on each other or know about each other.

I want to replace one of the contractcontracts, but not the other one. If I did truffle migrate --reset it would redeploy the one I want to keep, not to mention redeploying the "Migration" contract that it uses to keep track of what it's migrated. I thought the obvious thing to do was to make a new migration deploying the contract I'm changing and running truffle migrate without the --reset, and that seemed to work, but redeploying a contract over the previous one with the same name messed up the .json build file and caused my dapp to break expect extra function arguments that weren't there.

I think I can work through it by redeploying with a migration on mainnet, then doing a clean redeploy of the whole thing on testnet then editing the resulting build files by hand so that they know where to find the mainnet contracts, but this seems hackish and error-prone. Is there a "correct" way to do this?

I have a dapp consisting of two contracts, which don't particularly have a dependency on each other or know about each other.

I want to replace one of the contract, but not the other one. If I did truffle migrate --reset it would redeploy the one I want to keep, not to mention redeploying the "Migration" contract that it uses to keep track of what it's migrated. I thought the obvious thing to do was to make a new migration deploying the contract I'm changing and running truffle migrate without the --reset, and that seemed to work, but redeploying a contract over the previous one with the same name messed up the .json build file and caused my dapp to break expect extra function arguments that weren't there.

I think I can work through it by redeploying with a migration on mainnet, then doing a clean redeploy of the whole thing on testnet then editing the resulting build files by hand so that they know where to find the mainnet contracts, but this seems hackish and error-prone. Is there a "correct" way to do this?

I have a dapp consisting of two contracts, which don't particularly have a dependency on each other or know about each other.

I want to replace one of the contracts, but not the other one. If I did truffle migrate --reset it would redeploy the one I want to keep, not to mention redeploying the "Migration" contract that it uses to keep track of what it's migrated. I thought the obvious thing to do was to make a new migration deploying the contract I'm changing and running truffle migrate without the --reset, and that seemed to work, but redeploying a contract over the previous one with the same name messed up the .json build file and caused my dapp to break expect extra function arguments that weren't there.

I think I can work through it by redeploying with a migration on mainnet, then doing a clean redeploy of the whole thing on testnet then editing the resulting build files by hand so that they know where to find the mainnet contracts, but this seems hackish and error-prone. Is there a "correct" way to do this?

Source Link
Edmund Edgar
  • 16.9k
  • 1
  • 29
  • 58

How do I make truffle migrate replace just one contract?

I have a dapp consisting of two contracts, which don't particularly have a dependency on each other or know about each other.

I want to replace one of the contract, but not the other one. If I did truffle migrate --reset it would redeploy the one I want to keep, not to mention redeploying the "Migration" contract that it uses to keep track of what it's migrated. I thought the obvious thing to do was to make a new migration deploying the contract I'm changing and running truffle migrate without the --reset, and that seemed to work, but redeploying a contract over the previous one with the same name messed up the .json build file and caused my dapp to break expect extra function arguments that weren't there.

I think I can work through it by redeploying with a migration on mainnet, then doing a clean redeploy of the whole thing on testnet then editing the resulting build files by hand so that they know where to find the mainnet contracts, but this seems hackish and error-prone. Is there a "correct" way to do this?