1

I am using a nodejs application to add data to go-ethereum (geth) local environment using smart contracts and truffle. If for a reason or another anything happens and I need to stop geth and resume it later, I am not able to get the data. To reproduce:

ps -aux | grep geth
sudo kill -9 ProcessID
geth --datadir ./myDataDir --rpc --targetgaslimit 18446744073709551615 --networkid 1441 console 2>> myEth.log
miner.start()
personal.unlockAccount(personal.listAccounts[0], "Password", 0)
pm2 restart myApp

Error showing on NodeJS app when I try to use GET API of a data added before stopping geth:

0|myApp | 21-06 12:19:44.271: You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|myApp | Error: Invalid address passed to BankFactory.at(): 0x

This is obviously a conflict in allocating addresses, as it's not reading the correct address of the BankFactory. Contract addresses are usually generated when I do truffle deploy and then I copy contracts to my App's directory, but in this case they are still in my Node App, so it seems contracts on the blockchain itself are removed or changed!

How to fix that?

Ghassan Zein
  • 4,089
  • 3
  • 19
  • 30
  • The error is saying the contract address was not set. Can you add your client code? – Adam Kipnis Jun 22 '18 at 14:10
  • I found what was going wrong.. I wasn't copy/pasting the datadir, i was creating a new fresh one every time. copy/pasting it and running "geth --datadir ./myDataDir --rpc --networkid 1441 console 2>> myEth.log" made it work fine Thanks @AdamKipnis you always help – Ghassan Zein Jun 25 '18 at 08:28

0 Answers0