energywebfoundation / origin

Origin is a set of toolkits that together provide a system for issuance and management of Energy Attribute Certificates
https://energyweb.org/technology/ew-origin/
MIT License
104 stars 58 forks source link

Origin not able to connect to blockchain network using Metamask extension #669

Closed RohitGupta027 closed 4 years ago

RohitGupta027 commented 4 years ago

In continuation of the earlier issue #642 I am still facing the same issue Please make sure you've chosen the correct blockchain network and the contract address is valid. using local ganache network. I am using below setup

  1. node version : v12.16.1
  2. npm : 6.13.4
  3. solc version: 0.5.0+commit.1d4f565a.Darwin.appleclang
  4. solcjs version: 0.5.16+commit.9c3226ce.Emscripten.clang
  5. Metamask to connect ganache running on localhost:8545
  6. I have manually imported all accounts on metamask while initial boot-up of ganache-cli using yarn run:ganache
  7. commands to bootstrap application as you suggested in following sequence
    • yarn run:ganache
    • yarn run:backend
    • yarn run:demo
    • yarn run:ui

After this I get this error message on console even after switching the network from localhost to mainnet many times.

bundle.js:451877 ContractsSaga::WrongNetwork Error: Returned values aren't valid, did it run Out of Gas? You might also see this error if you are not using the correct ABI for the contract you are retrieving data from, requesting data from a block number that does not exist, or querying a node which is not fully synced.
    at ABICoder.../../node_modules/web3-eth-contract/node_modules/web3-eth-abi/src/index.js.ABICoder.decodeParameters (bundle.js:216412)
    at Contract.../../node_modules/web3-eth-contract/src/index.js.Contract._decodeMethodReturn (bundle.js:218443)
    at Method.outputFormatter (bundle.js:218796)
    at Method.../../node_modules/web3-eth-contract/node_modules/web3-core-method/src/index.js.Method.formatOutput (bundle.js:215148)
    at sendTxCallback (bundle.js:215523)
    at bundle.js:210761
    at inpage.js:1
    at inpage.js:1
    at i (inpage.js:1)
    at inpage.js:1

Can you please suggest what's going wrong?

e00dan commented 4 years ago

@RohitGupta027 Can you post the log of yarn run:demo command?

RohitGupta027 commented 4 years ago
yarn run v1.22.0
$ lerna run start --scope @energyweb/migrations --stream
lerna notice cli v3.20.2
lerna info versioning independent
lerna notice filter including "@energyweb/migrations"
lerna info filter [ '@energyweb/migrations' ]
lerna info Executing command in 1 package: "yarn run start"
@energyweb/migrations: $ ts-node src/deploy
@energyweb/migrations: Connected to the WebSocket event server on: ws://localhost:3031
@energyweb/migrations: (node:54842) UnhandledPromiseRejectionWarning: Error: Request failed with status code 400
@energyweb/migrations:     at createError (/Users/rohit.gupta/shell/blockchain/ewf/origin/node_modules/axios/lib/core/createError.js:16:15)
@energyweb/migrations:     at settle (/Users/rohit.gupta/shell/blockchain/ewf/origin/node_modules/axios/lib/core/settle.js:17:12)
@energyweb/migrations:     at IncomingMessage.handleStreamEnd (/Users/rohit.gupta/shell/blockchain/ewf/origin/node_modules/axios/lib/adapters/http.js:236:11)
@energyweb/migrations:     at IncomingMessage.emit (events.js:323:22)
@energyweb/migrations:     at IncomingMessage.EventEmitter.emit (domain.js:482:12)
@energyweb/migrations:     at endReadableNT (_stream_readable.js:1204:12)
@energyweb/migrations:     at processTicksAndRejections (internal/process/task_queues.js:84:21)
@energyweb/migrations: (node:54842) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
@energyweb/migrations: (node:54842) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
e00dan commented 4 years ago

The log indicates there was a problem - 400 code coming from backend service. Can you post log of yarn run:backend?

Also, before deploying new demo, please remove the backend database first. For example, instead of running yarn run:backend from root directory, run:

rm -rf db.sqlite && yarn start:dev

from inside packages/origin-backend directory

RohitGupta027 commented 4 years ago

Worked like charm by running rm -rf db.sqlite && yarn start:dev from project directory. Earlier I started the backend from the root directory and it does start without any error but then yarn run:demo was giving error 400 . Any idea what causes the issue before?

e00dan commented 4 years ago

So, after you deploy demo once, then you need to clear database and restart origin-backend. The easiest way to do it is to find db.sqlite and remove it.

RohitGupta027 commented 4 years ago

Thanks @Kuzirashi for your quick responses and provide solution.