-
Ethers Versionv5 Search Termsbsc Describe the ProblemError: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.4) Code Snippetconst provider = new ethers.providers.JsonRpcProvider("https://bsc-dataseed.binance.org/");
const getBalance_chan = async (address: string) => {
return await provider.getBalance(address)
} Contract ABI"function balanceOf(address account) public view returns (uint256)", ErrorsError: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.4)
reason: 'could not detect network',
code: 'NETWORK_ERROR',
event: 'noNetwork' EnvironmentNo response Environment (Other)No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This means your network (or node, at least) does not support the eth_chainId RPC method. I believe on BSC this can be caused by CORS issues, or sometimes the backend is less reliable and doesn’t respond. You can pass the network object in as the second parameter, and should probably use the StaticJsonRpcProvider instead of the normal JsonRpcProvider. You can also check out this package: https://github.com/ethers-io/ancillary-bsc Let me know if that helps. :) |
Beta Was this translation helpful? Give feedback.
This means your network (or node, at least) does not support the eth_chainId RPC method. I believe on BSC this can be caused by CORS issues, or sometimes the backend is less reliable and doesn’t respond.
You can pass the network object in as the second parameter, and should probably use the StaticJsonRpcProvider instead of the normal JsonRpcProvider.
You can also check out this package: https://github.com/ethers-io/ancillary-bsc
Let me know if that helps. :)