2

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
              },       
            };  
  
2

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
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.