You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Purpose: instructions to download and create a script that allows users to query a subnet and discover the future next adjustment interval block will be (and provide an approximate time to adjustment), using a terminal window.
If you have not installed yarn yet, run npm install --global yarn (if you are not root, you may need sudo npm install --global yarn)
Run yarn add @polkadot/api
Run yarn add prompt-sync
Save the following into a file (for example: "bittensor_check-interval.js")
const { ApiPromise, WsProvider } = require("@polkadot/api");
const prompt = require("prompt-sync")();
// If you do not want to be prompted for network when running the script,
// change this variable to "finney" to default to the finney endpoint,
// or "local" if you want to default to your own subtensor endpoint.
let network = "";
// If you have your own local subtensor and want to use its entry point, specify
// your entrypoint's wss address here (e.g., "wss://127.0.0.1:443")
let localNetworkEntryPoint = "";
if (network === "") {
network = prompt("Enter network (finney, subvortex, local): ");
}
if ((network === "local" || network === "l") && localNetworkEntryPoint != "") {
networkEntryPoint = localNetworkEntryPoint;
} else {
networkEntryPoint = "wss://entrypoint-finney.opentensor.ai:443";
}
let subnet = prompt("Enter subnet netuid to query:");
if (!(Number.isInteger(subnet)) || subnet < 1 || subnet > 32) {
subnet == 1;
} else {
subnet == subnet;
}
async function queryBittensorData() {
const wsProvider = new WsProvider(
networkEntryPoint );
const api = await ApiPromise.create({ provider: wsProvider });
const [
lastAdjustmentBlock,
adjustmentInterval,
currentBlock,
] = await Promise.all([
api.query.subtensorModule.lastAdjustmentBlock(subnet),
api.query.subtensorModule.adjustmentInterval(subnet),
api.query.system.number(),
]);
let nextAdjustmentBlock = lastAdjustmentBlock.toNumber() + adjustmentInterval.toNumber();
let currentBlockNumber = currentBlock.toNumber();
let blocksToGo = nextAdjustmentBlock - currentBlockNumber;
console.log(`Information for subnet`,subnet);
console.log(`-=-=-=-=-=-=-=-=-=-=-=-=-=-`);
console.log(`Last Adjustment Block: ${lastAdjustmentBlock.toNumber()}`);
console.log(`Adjustment Interval: ${adjustmentInterval.toNumber()}`);
console.log(`Next Adjustment Block: `, nextAdjustmentBlock);
console.log(`Current Block: `, currentBlockNumber);
console.log(`Blocks to go:`,blocksToGo,`in approximately`,blocksToGo*12,`seconds (`,blocksToGo*12/60,`minutes).`);
}
queryBittensorData()
.catch(console.error)
.finally(() => process.exit());
console.warn = () => {};
You can run this file via node <filename> (for example: node bittensor_check-interval.js)
The text was updated successfully, but these errors were encountered:
By: @rajkaramchedu and @Jackalgirl
Purpose: instructions to download and create a script that allows users to query a subnet and discover the future next adjustment interval block will be (and provide an approximate time to adjustment), using a terminal window.
Instructions:
npm install --global yarn
(if you are not root, you may needsudo npm install --global yarn
)yarn add @polkadot/api
yarn add prompt-sync
node <filename>
(for example:node bittensor_check-interval.js
)The text was updated successfully, but these errors were encountered: