This script extracts the ‘randao’ information from the Beacon chain block details in JavaScript using the Axios package.
Prerequisites
Environment setup
Import the package and set up the request details
index.js
, import the axios library, and initialize the parameters required for this request.This script will send a GET
request to the Ethereum Beacon chain.Paste your Beacon Chainstack node URL in the BEACON_PROVIDER_URL
const.Also, set up the request parameters. The BLOCK_ID
constant identifies which block to query.Send the request
Slot and randao
slot,
and randao
fields of the object returned.They are held in the respective constants and you can wrap this code in a function to return those values and do more processing.Run the script
node index
This command will run the program and display the response.