trufflesuite / ganache

:warning: The Truffle Suite is being sunset. For information on ongoing support, migration options and FAQs, visit the Consensys blog. Thank you for all the support over the years.
https://consensys.io/blog/consensys-announces-the-sunset-of-truffle-and-ganache-and-new-hardhat?utm_source=github&utm_medium=referral&utm_campaign=2023_Sep_truffle-sunset-2023_announcement_
MIT License
2.62k stars 678 forks source link

ganache-cli Forking Infura ETH mainnet Endpoint, gets error "The fork provider errored when checking net_version" #3707

Closed baizetianxia closed 2 years ago

baizetianxia commented 2 years ago

When forking https://mainnet.infura.io/v3/project_id, I get the error:

Error: The fork provider errored when checking net_version: Invalid JSON RPC response: ""
    at /Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2093582
    at Object._fireError (/Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:67075)
    at s (/Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:4:114003)
    at a (/Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2108912)
    at /Users/xxx/.nvm/versions/node/v16.15.1/lib/node_modules/ganache-cli/build/ganache-core.node.cli.js:55:2093154
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

The URL does respond to a CURL request:

$ curl --url https://mainnet.infura.io/v3/project_id -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}'
{"jsonrpc":"2.0","id":1,"result":"1"}%

Dev envirnment MacOS :12.0.1 , M1 node 12.22.12,16.13.2 Ganache CLI v6.12.2 (ganache-core: 2.13.2)

davidmurdoch commented 2 years ago

What is the exact command you are running? Does ganache --fork mainnet work for you?

baizetianxia commented 2 years ago

@davidmurdoch hello, I just exected ganache-cli --fork https://mainnet.infura.io/v3/project_id. Got "Error: The fork provider errored when checking net_version: Invalid JSON RPC response: """ ganache-cli --fork mainnet didnot wok. Got "Error: The fork provider errored when checking net_version: connection not open on send()"

davidmurdoch commented 2 years ago

I just noticed you are using Ganache v6, which is very old. Please update to the ganache package by running:

$ npm uninstall ganache-cli -g
$ npm install ganache -g
baizetianxia commented 2 years ago

Thanks a lot. My problem of ganache-cli has been solved according to your suggestions.