This Node.js script fetches the latest block height from specified Axelar RPC endpoints. It makes repeated requests to the endpoints, logs the block height, and includes error handling.
Install Node.js If Node.js is not already installed, you can install it using the following commands:
sudo apt update && sudo apt upgrade -y
sudo apt install nodejs npm -y
Install Required Node.js Packages Install the axios package using npm:
npm install axios
- Clone the Repository:
git clone https://github.com/Hafxhak/AXELAR-data-fetcher.git
cd AXELAR-data-fetcher
- Edit the Script:
Open the script in a text editor:
nano index.js
Replace the placeholder URLs in the rpcUrls list with your own Axelar RPC endpoint URLs. Example:
const rpcUrls = [
'https://tm.axelar.lava.build/lava-referer-your-unique-id/', // replace with your main-net RPC
'https://tm.axelar-testnet.lava.build/lava-referer-your-unique-id/', // replace with your test-net RPC
];
Save and exit the editor (for nano, press CTRL + X, then Y, and Enter).
- Install and Use Screen:
Install screen to run the script in a detached session:
sudo apt install screen -y
screen -S axelar
- Run the Script:
Execute the script using Node.js:
node index.js
The script will log the latest block height from the RPC endpoint for each request. Example output:
Latest Block Height for https://tm.axelar.lava.build/lava-referer-your-unique-id/: 12345
- Detach from the Screen Session:
Detach from the screen session without stopping the script by pressing CTRL + A, then D.