filecoin-project / filecoin-fvm-localnet

A complete filecoin lotus and boost docker image to spin up a localnet for smart contract development
MIT License
13 stars 8 forks source link

Metamask won't accept network manually: lotus node RPC error #11

Closed kylegranger closed 1 year ago

kylegranger commented 1 year ago

I love the videos, and this is a very cool project. But I'm stuck at the point trying to connect my Metamask wallet to the localnet. I'm entering the correct parameters

I do see the instance of Lotus Node is getting hit with a request, but it results in an error

2023-09-08T19:58:32.991+0200    ERROR   rpc     go-jsonrpc@v0.3.1/server.go:108 RPC Error: Invalid request
2023-09-08T19:58:32.991+0200    WARN    rpc     go-jsonrpc@v0.3.1/server.go:118 rpc error: Invalid request

In Metamask, I get:

Could not fetch chain ID. Is your RPC URL correct?

Interestingly, I get the same error running lotus directly: cloning https://github.com/filecoin-project/lotus, without docker, starting up the daemon.

I suspect it might have to do with the lack of Authorization header.

When I allocate an API token (lotus auth create-token --perm sign), and pass it in via a curl command calling the eth_chainId method, it succeeds, returning the hex version of 31415926. WIthout the header, I get an error.

curl --location 'http://127.0.0.1:1234/rpc/v1' \
--header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJBbGxvdyI6WyJyZWFkIiwid3JpdGUiLCJzaWduIl19.D5Vjz4S8DVb3MCcU-pLQBXwscrv5Wk0JwnixLrwo5Lg' \
--header 'Content-Type: application/json' \
--data '{"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1}'

Thank you for any ideas about what I might be doing wrong!

Platform: Ubuntu 22.04, Firefox browser, Metamask 10.34.0