-
Ethers Version6.2.3 Search TermsgetNetwork, empty Describe the Problemtrying to get provide network using code snippet below, the network is an empty object. I think the result is supposed to be something like mainnet network, because it connects to mainnet. Code Snippetimport { ethers } from "ethers";
// change xxxx to actual key
const ALCHEMY_MAINNET_URL = 'https://eth-mainnet.g.alchemy.com/v2/xxxx';
const providerETH = new ethers.JsonRpcProvider(ALCHEMY_MAINNET_URL)
const network = await providerETH.getNetwork();
console.log(network); Contract ABINo response ErrorsNo response EnvironmentEthereum (mainnet/ropsten/rinkeby/goerli) Environment (Other)No response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It’s not empty, it’s a JavaScript instance of a class, which only included enumerated properties in the default console.log. You can either use a custom logger (I believe node’s |
Beta Was this translation helpful? Give feedback.
It’s not empty, it’s a JavaScript instance of a class, which only included enumerated properties in the default console.log. You can either use a custom logger (I believe node’s
console.dir
accepts an optional parameter to recurse over internal properties) or just access the fields you wish. :)