3

Here is the doc about provider in ethers 5.x document:

new ethers.providers.JsonRpcProvider( [ urlOrConnectionInfo [ , networkish ] ] )

Connect to a JSON-RPC HTTP API using the URL or ConnectionInfo urlOrConnectionInfo connected to the networkish network.

If urlOrConnectionInfo is not specified, the default (i.e. http://localhost:8545) is used and if no network is specified, it will be determined automatically by querying the node using eth_chaindId and falling back on eth_networkId.

What is the networkish for urlOrConnectionInfo below?

let connectionInfo = {
              url: 'http://my-ip:80',
              headers: {
                "Bearer": "eyJhbGciOiJSUzI1NiIsInR5cCI6...."  //<<==RS256 JWT token
              },       
            };

user938363
  • 669
  • 1
  • 6
  • 23

1 Answers1

3

From the Ethers docs on Networks:

Any API that accept a Networkish can be passed a common name (such as "mainnet" or "ropsten") to use that network definition or may specify custom parameters.

From the source code here it looks like a networkish can be a few things:

  • a string name ("mainnet")
  • a chain number (1)
  • a Network object (defined right above a networkish in the code linked above):
export type Network = {
    name: string,
    chainId: number,
    ensAddress?: string,
    _defaultProvider?: (providers: any, options?: any) => any
}
Linum Labs
  • 1,448
  • 6
  • 18