diff --git a/packages/web3-rpc-methods/src/net_rpc_methods.ts b/packages/web3-rpc-methods/src/net_rpc_methods.ts index 7b638cf59a9..c057ee99c34 100644 --- a/packages/web3-rpc-methods/src/net_rpc_methods.ts +++ b/packages/web3-rpc-methods/src/net_rpc_methods.ts @@ -14,9 +14,16 @@ GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with web3.js. If not, see . */ + import { Web3RequestManager } from 'web3-core'; import { Web3NetAPI } from 'web3-types'; +/** + * Fetches the network ID of the current Ethereum network. + * This corresponds to the `net_version` RPC call. + * @param requestManager - An instance of `Web3RequestManager` to send the RPC request. + * @returns A Promise that resolves to the network ID as a string. + */ export async function getId(requestManager: Web3RequestManager) { return requestManager.send({ method: 'net_version', @@ -24,6 +31,12 @@ export async function getId(requestManager: Web3RequestManager) { }); } +/** + * Fetches the number of connected peers to the Ethereum network. + * This corresponds to the `net_peerCount` RPC call. + * @param requestManager - An instance of `Web3RequestManager` to send the RPC request. + * @returns A Promise that resolves to the peer count as a hexadecimal string. + */ export async function getPeerCount(requestManager: Web3RequestManager) { return requestManager.send({ method: 'net_peerCount', @@ -31,9 +44,16 @@ export async function getPeerCount(requestManager: Web3RequestManager) { return requestManager.send({ method: 'net_listening', params: [], }); } +