Closed luiztools closed 1 year ago
Here, another (and simpler) example that fires the exact same error:
const provider = new ethers.AlchemyProvider(${process.env.NETWORK}
, ${process.env.ALCHEMY_API_KEY}
);
const balance = await provider.getBalance(${process.env.WALLET}
);
console.log(balance);
Just to mention: I tried all the Ethers versions with the support of Polygon Mumbai (since 6.2, I guess). All fired the same error. I've cleaned and installed the dependencies again for each test.
I am getting a SERVER_ERROR
when I try, which makes sense as my API key is likely out of capacity.
You error is coming from socks-proxy-agent
, so maybe you have a library that is hijacking the global http
library or the fetch
command (if in the Browser)?
You are right, thanks. I removed all the other libraries and it worked like a charm. I found that one lib specifically causes the error when used together with ethers (node-binance-api). Do you have any clue if there a way that I can isolate ethers and http from another libs? Maybe a http module copy, maybe some scope isolation, I don't know...
With Ethers v6, you can override the web fetching library using FetchRequest.registerGetUrl
and provide your own implementation. Maybe that library offers a hook into the original library they are hijacking, that you could plug in?
Do you know why they are forcing the connection over a socks5 proxy? Maybe there is a way to configure the library to skip that?
Ethers Version
6.6.1
Search Terms
alchemy,alchemyprovider
Describe the Problem
The function below, that works fine on InfuraProvider and BrowserProvider, doesn't work with AlchemyProvider. The complete error is below too.
I'm using Node.js v18.16.1 and I've tried ChatGPT too and it gives me almost the same code. In the Ethers docs, we don't have a complete example, but with the pieces, the resulting code is the same. I didn't found anything about it on StackOverflow too.
I'd appreciate any help.
Code Snippet
Contract ABI
Errors
Environment
Altcoin - Please specify (e.g. Polygon)
Environment (Other)
Polygon Mumbai