Returns the current network id.
none
String - The current network id.
String
const Web3 = require("web3"); async function main() { const Web3 = require('web3') const rpcURL = '1DLT-IP-ADDRESS' // Your RPC URL goes here const web3 = new Web3(rpcURL) // Query the blockchain (replace example parameters) const id = await web3.eth.net_version(); // Print the output to console console.log(id); } main();
const { ethers } = require("ethers"); async function main() { // Initialize an ethers instance const provider = new ethers.providers.JsonRpcProvider("1DLT-IP-ADDRESS"); // Query the blockchain (replace example parameters) const id = await provider.net_version(); // Print the output to console console.log(id); } main()
curl 1DLT-IP-ADDRESS \ -X POST \ -H "Content-Type: application/json" \ -d '{"jsonrpc":"2.0","method":"net_version","params":[],"id":67}'
{ "id":67, "jsonrpc": "2.0", "result": "0x3d" }
Last updated 2 years ago