Using web3js it is possible get network ID using the following method:
// Contract ABI Load
const ABISimpleStorage = require("./build/contracts/SimpleStorage.json");
// Besu Connection Web3 Load
let web3 = new Web3(
new Web3.providers.WebsocketProvider("ws://127.0.0.1:8546")
);
const netID = await web3.eth.net.getId();
How we could do same thing in ethers.js?
const ABISimpleStorage = require("./build/contracts/SimpleStorage.json");
let provider = new ethers.providers.JsonRpcProvider();
let contract = new ethers.Contract(
ABISimpleStorage.networks["2020"].address,
ABISimpleStorage.abi,
provider
);
Thanks