net_version

Returns the current network id.

Parameters

none

Returns

String - The current network id.

Request

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();

Result

{
  "id":67,
  "jsonrpc": "2.0",
  "result": "0x3d"
}

Last updated