In an expo managed workflow project etherjs fails with Parse error from the server
See original GitHub issueThe below code throws an exceptions
useEffect(() => {
async function doSomething() {
try {
const provider = new AlchemyProvider(
'kovan',
"*********************"
);
const network = await provider.ready;
console.log({ network });
console.log({ connection: provider.connection });
const blockNumber = await provider.getBlockNumber();
console.log({ blockNumber });
} catch (e) {
console.log("Failed:", e.message);
}
}
doSomething();
}, []);
Exception
Failed: bad response (status=400, headers={"date":"Sun, 28 Feb 2021 00:27:35 GMT","vary":"Origin","content-type":"application/json","content-length":"83","server":"Apache"}, body="{\"jsonrpc\": \"2.0\", \"id\": null, \"error\": {\"code\": -32700, \"message\": \"Parse error\"}}", requestBody="{\"method\":\"eth_blockNumber\",\"params\":[],\"id\":42,\"jsonrpc\":\"2.0\"}", requestMethod="POST", url="https://eth-kovan.alchemyapi.io/v2/***********", code=SERVER_ERROR, version=web/5.0.13)
other logs:
Object {
"network": Object {
"_defaultProvider": [Function func],
"chainId": 42,
"ensAddress": null,
"name": "kovan",
},
}
Object {
"connection": Object {
"allowGzip": true,
"throttleCallback": [Function throttleCallback],
"url": "https://eth-kovan.alchemyapi.io/v2/****************",
},
}
If rather than configuring the AlchemyProvider I use getDefaultProvider(‘network’) it works but of course the connections are throttled.
I have another project with the same code that works but it’s configured with “bare workflow”. Both projects have the Etherjs shim (but I don’t think it matters)
I could reproduce the problem with Curl:
curl --location --request POST 'https://eth-kovan.alchemyapi.io/v2/lbJ3HMDaSHXyDaZ6r_1h1HUQpA84OQVp' \
--header 'Content-Type: text/plain' \
--data-raw '{\"method\":\"eth_blockNumber\",\"params\":[],\"id\":42,\"jsonrpc\":\"2.0\"}'
In this case, I got the Parse error
Rather than if I do:
curl --location --request POST 'https://eth-kovan.alchemyapi.io/v2/lbJ3HMDaSHXyDaZ6r_1h1HUQpA84OQVp' \
--header 'Content-Type: application/json' \
--data-raw '{"method":"eth_blockNumber","params":[],"id":42,"jsonrpc":"2.0"}'
I got the correct response.
So it seems Etherjs is serializing in two different ways in my two expo projects.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
In an expo managed workflow project etherjs fails with Parse error ...
The below code throws an exceptions useEffect(() => { async function doSomething() { try { const provider = new AlchemyProvider( 'kovan', ...
Read more >expo ios command exited with error code 65 - Stack Overflow
I am trying to use revenueCat on my expo managed workflow project using this tutorial. I am trying to test the project by...
Read more >Eject successful but build failing for AppAuth on ios parse error
I did: expo eject from CLI with option to ExpoKit, it was succesful: Epyons-iMac:The-Masjid-App-Mobile epyon$ expo eject Your git working ...
Read more >How To Eject From Expo Managed Workflow to Bare? - Pagepro
When you encounter limitations in the Expo managed workflow, ... Why using Expo instead of starting with a plain React Native project?
Read more >A Framework for Building Native Applications using React
Component-Based. Build encapsulated components that manage their state, then compose them to make complex UIs. Developer Velocity. See local changes in seconds.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Cool. I can look more into that tomorrow. I don’t use Expo, so I don’t know what
bareand whatnot mean, but I can experiment.You must specify all the API keys. You are missing
etherscanandpocket. If you add those, you should stop getting that warning in your console. The performance and security of your app will also be improved. 😃your metro config should include this:
see this repo for more details https://github.com/draftbit/expo-walletconnect-demo
idk you can close this @ricmoo