0

Is it possible to deploy the same contract with different addresses? When I try it in truffle, it is able to generate a new contract with a different contract address, but when I do Contract.address it returns the inital contract address I generated and not any of the new ones.

1

Use the --reset flag when deploying using truffle.

truffle migrate --reset

documentation

0

Yes, every time you deploy the contract it will be stored at a new address. If you use truffle migrate, you can see the log in the console telling you the tx hash and address where it got deployed.

The problem seems to be with your front-end code, you might be still referencing the first contract. Can you share the complete code?

  • I'm running everything in truffle console still, no front-end connecting to it. I have const contract1 = Contract.new().then(instance => {return instance;}) and then I run contract1.address – JorahFriendzone Nov 30 '17 at 21:04
  • The problem is that you are not correctly assigning the result of the call to the variable. You should do it like this: var contract1 = Contract.new().then(instance => {contract1 = instance;}). Then var contract2 = Contract.new().then(instance => {contract2 = instance;}) Now you can do contract1.address and contract2.address – pabloruiz55 Nov 30 '17 at 21:22
  • I realized that while testing, thanks though. Now how would I deploy this on the front end? I can't just directly use Contract.new().then(instance => {contract1 = instance;}) in a javascript file right? – JorahFriendzone Nov 30 '17 at 21:30
  • Yes, you can. There are a few other steps you have to do first, but the code above is JS, so you can, once you have done the proper setup. github.com/trufflesuite/truffle-contract – pabloruiz55 Nov 30 '17 at 21:44

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.