-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
32 lines (26 loc) · 981 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { ethers } = require('ethers');
// RPC URL - use environment variable or default to the main RPC
const RPC_URL = process.env.PROST_RPC_URL || 'https://rpc.powerloom.network/';
async function getLatestBlockNumber() {
try {
// Create a provider
const provider = new ethers.JsonRpcProvider(RPC_URL);
console.log(`Using RPC URL: ${RPC_URL}`);
// Get the latest block number
const blockNumber = await provider.getBlockNumber();
console.log(`Latest block number: ${blockNumber}`);
return blockNumber;
} catch (error) {
console.error('Error fetching latest block number:', error.message);
return null;
}
}
// Test the function
getLatestBlockNumber().then((result) => {
if (result !== null) {
console.log('✅ Successfully fetched the latest block number. Your ISP is supported!');
} else {
console.log('❌ Failed to fetch the latest block number. Your ISP/VPS region is not supported ⛔️');
}
process.exit(0);
});