// Import
import { ApiPromise, WsProvider } from "@polkadot/api";
// Construct
/*
https://rpc.kulupu.network
https://rpc.kulupu.network/ws
https://rpc.kulupu.corepaper.org
https://rpc.kulupu.corepaper.org/ws
*/
(async () => {
//const wsProvider = new WsProvider('wss://rpc.polkadot.io');
const wsProvider = new WsProvider("wss://rpc.kulupu.network/ws");
const api = await ApiPromise.create({ provider: wsProvider });
// Do something
const chain = await api.rpc.system.chain();
console.log(`You are connected to ${chain} !`);
console.log(await api.query.difficulty.pastDifficultiesAndTimestamps.toJSON());
console.log(api.genesisHash.toHex());
})();
How do I get difficulty over time from Kulupu (polkadotjs)?
155 views Asked by chovy At
1
There are 1 answers
Related Questions in BLOCKCHAIN
- Sepolia test network ID
- Gas Estimation Fee on Tron Mainnet
- This is the solidity code to list nft in marketplace after minting but while calling makeItem function Error is showing that Faliled to estimate gas
- Trying to send transactions via a signer using my private key
- My question is regarding installation of a package in VS code but im getting an error in installing it
- Historical data scrapping / collection for Ethereum
- Installation Private Blockchain
- How to import rpc information without importing .env file or hardcoding on frontend?
- How do I speed up transaction filtering on solan blockchain?
- Undeclared identifier: VRF_V2_Wrapper.calculateRequestPrice()
- how to interpret and format iterest rates and index returned by aave event
- Can I swap with 1inch swap apis with forked hardhart?
- How to connect metamask to flutter mobile app
- Scraping 'offers' data from OpenSea
- Which web3 decentralized wallet is suitable to store my crypto assets and lock some of the tokens for certain time?
Related Questions in POLKADOT
- Unable to Connect Polkadot.js Apps to Dockerized Aleph-nodes in WSL2
- Polkadot `payment_queryInfo` returning Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
- Way to cancel a signature request in Polkadot Extension
- I am attempting the quick start tutorial and I am at this command "cargo build --release --package node-template-runtime" on this page
- "cargo check -p node-template-runtime --release" error: failed to select a version for `signature`
- Substrate: How to perform Parachain Runtime Upgrade via Democracy using Chopsticks
- How to get Polkadot address from private key?
- rococo parachain stop generate blocks
- How to create a polka dot texture with linear gradient as background in css?
- running substrate benchmaks errors at setjmp file not found
- First Substrate Chain
- How to generate polkadot account file using polkadot-js API
- Polkadot block-chain basic concepts
- 1002: Verification Error: Execution: Could not convert parameter `tx` between node and runtime: No such variant in enum MultiAddress
- Create an array within a 'for loop' in React
Related Questions in POLKADOT-JS
- React with Typescript Array of promises
- Unable to Connect Polkadot.js Apps to Dockerized Aleph-nodes in WSL2
- Polkadot `payment_queryInfo` returning Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
- Way to cancel a signature request in Polkadot Extension
- Decoding problems in polkadot-js after updating of substrate version
- Unable to upload smart contract in Polkadot.js - contracts.instantiateWithCode: ready the whole time
- How to import an account to Keyring which was exported from the polkadot{.js] browser extension?
- First Substrate Chain
- Polkadot.js sr25519 secret key to hex
- How to call Openbrush contract from Front-end app
- "contract" can be obtained as a result of "signAndSend", but the compilation error is not resolved
- How to get unique smart contract errors in a frontend app using polkadot.js
- Polkadot.js "signAndSend" function causes "signer" option to compile error
- An Reference Error is occured at "@polkadot/extension-dapp/bundle.js"
- Why does nodejs wait a long time before exiting
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
The storage item
pastDifficultiesAndTimestampsonly holds the last 60 blocks worth of data. For getting that information you just need to fix the following:If you want to query the difficulty of a blocks in general, a loop like this will work:
Note that this requires an archive node which has informaiton about all the blocks. Otherwise, by default, a node only stores ~256 previous blocks before state pruning cleans things up.
If you want to see how to make a query like this, but much more efficiently, look at my blog post here:
https://www.shawntabrizi.com/substrate/porting-web3-js-to-polkadot-js/