首页 > 解决方案 > geth 使用智能合约备份/恢复添加到区块链的数据

问题描述

我正在使用 nodejs 应用程序使用智能合约和松露将数据添加到 go-ethereum (geth) 本地环境。如果由于某种原因或其他任何事情发生并且我需要停止 geth 并稍后恢复它,我将无法获取数据。重现:

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

当我尝试使用在停止 geth 之前添加的数据的 GET API 时,NodeJS 应用程序上显示错误:

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

这显然是分配地址的冲突,因为它没有读取 BankFactory 的正确地址。合同地址通常是在我这样做时生成的truffle deploy,然后我将合同复制到我的应用程序的目录中,但在这种情况下,它们仍在我的节点应用程序中,因此区块链本身的合同似乎被删除或更改了!

如何解决?

标签: ubuntublockchainethereumsmartcontractsgo-ethereum

解决方案


推荐阅读