Unable to immediately read the chainId of the network
Ethers Version
6.*
Search Terms
No response
Describe the Problem
Provided Network for JsonRpcProvider, but was unable to read the chainId of the network. In other environments, I am unable to determine which chain this provider belongs to
const network = new Network('https:...', 44)
const provider = new JsonRpcProvider('https...', network)
// error: ethers network is not available yet
provider._network.chainId
when specifying the network, _network should be readable, It shouldn't have to wait for a while to obtain it
Code Snippet
No response
Contract ABI
No response
Errors
No response
Environment
No response
Environment (Other)
No response
To access the _network synchronously, I think you need to configure it as a static network; try new JsonRpcProvider(url, network, { staticNetwork: true }).
I've confirmed that this works as expected; if the network is configured as static the ._network is immediately available.
Let me know if you have any questions about this. :)