// 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)?
152 Views Asked by chovy At
1
There are 1 best solutions below
Related Questions in BLOCKCHAIN
- Blockchain receive API with same address
- panic: runtime error: invalid memory address or nil pointer dereference when running Blockchainr
- Cannot "Query" hyperledger-fabric, error code -32003
- Why is transactions not always record to the block? - Blockchain PBFT
- Hyperledger on Bluemix: Failed to launch chaincode spec(Could not get deployment transaction
- Connect to Multichain network using aws EC2
- Deploying Ethereum Private Network
- Does the "holy trinity" (Ethereum, Swarm and Whisper) support multimedia streaming?
- Hyperledger Fabric v0.6 using Docker Toolbox
- What is the ibm bluemix blockchain port for events?
- Unable to deploy Hyperledger Java chaincode via Github
- How to accurately measure the effort required to reduce a λ-term?
- IBM Blockchain (Hyperledger) - "Error when deploying chaincode"
- Transaction via Blockchain API using Multiple recipients
- Computing acoustic fingerprint in a distributed manner without exposing the whole file to any participant
Related Questions in POLKADOT
- How to clean up substrate runtime compiled result and compile again
- Cannot connect front-end template to node-template in Substrate
- Error Connecting to Substrate: Unable to initialize the API: createType(StorageKey):: Derived
- Getting the reward points of a validator by account
- How to create a substraste chain?
- Polkadot `payment_queryInfo` returning Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
- Unable to Connect Polkadot.js Apps to Dockerized Aleph-nodes in WSL2
- How to update state of reactjs in realtime from an polkadotjs rpc api?
- Blocks are not being finalized in a private network
- How to restart a substrate node
- yarn add installs multiple versions, [how to] ensure that there is only one installed?
- Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts
- polkadot.js: Unable to create Enum
- How do I get difficulty over time from Kulupu (polkadotjs)?
- How to query for Polkadot transaction info using only txHash?
Related Questions in POLKADOT-JS
- How do you format balances with the Polkadot JS API?
- Error Connecting to Substrate: Unable to initialize the API: createType(StorageKey):: Derived
- Getting the reward points of a validator by account
- Polkadot `payment_queryInfo` returning Execution aborted due to trap: wasm trap: wasm `unreachable` instruction executed
- Unable to Connect Polkadot.js Apps to Dockerized Aleph-nodes in WSL2
- How to update state of reactjs in realtime from an polkadotjs rpc api?
- Polkadot App js UI - "waiting to make a connection to the remote endpoint and finishing API initialization
- Contract call returns error "Found input with 28 bits, expected 8". Polkadot.js and ink contracts
- polkadot.js: Unable to create Enum
- How do I get difficulty over time from Kulupu (polkadotjs)?
- How to query for Polkadot transaction info using only txHash?
- Connect via WSS to Polkadot Full Noder running on local network failed
- How to get the Polkadot address from the polkadot public key? Polkadot.js
- How to query substrate storage via `.entries` for partial items
- encoding struct in polkadot.js api
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)
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?
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/