2

I’m trying to create sort of private chain on testrpc so i use testrpc -u 0 -d --db /path/to/db to start testrpc each time. The thing is that if I restart testrpc (kill it and start it again) truffle migrate restarts migration process from the beginning (1_*) although testrpc uses old chain database. Is there a way around this or is this an issue?

4

When you deploy a contract to your private chain. Truffle stores the network id of your chain to know on what chain it was deployed. ( with the address on the current chain )

in build/contract/yourContract.json there is a field

"networks": {
 "1": {  //live network
  "events": {},
  "links": {},
  "address": "0xd77d2a7a728dc7c7c58ac1bcfdfb35934b3ed066"
 },
 "15": { // network id I manually set
  "events": {},
  "links": {},
  "address": "0x1c10cbe2e883567eea5de1017f3d21b5b2600abb"
 },
 "1507630284099": { // timestamp generated by testrpc
  "events": {},
  "links": {},
  "address": "0xcdc26c0a2e7f43f4ad571373fc68c1a58ed8a25a"
 }
},

The issue you have is that you do not set your network id with testrpc.

use

-i or --network-id: Specify the network id the TestRPC will use to identify itself (defaults to the current time or the network id of the forked blockchain if configured) doc

testrpc -u 0 -d --db /path/to/db --network-id=15

to set an id so when you restart your testrpc you'll keep your database and when you'll run again truffle migrate it will tell you Network up to date.

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.