Providers
WsProvider
import { WsProvider } from 'dedot';
// Initialize the provider & connect to the network
const provider = new WsProvider('wss://rpc.polkadot.io');
await provider.connect();
// Fetch the genesis hash
const genesisHash = await provider.send('chain_getBlockHash', [0]);
console.log(genesisHash);
// Subscribe to runtimeVersion changes
await provider.subscribe({
subname: 'chain_newHead', // subscription name for notification
subscribe: 'chain_subscribeNewHeads', // subscribe method
params: [], // params for subscribe method
unsubscribe: 'chain_unsubscribeNewHeads', // unsubscribe method
}, (error, newHead, subscription) => {
console.log('newHead', newHead);
});
// Disconnect from the network
await provider.disconnect();SmoldotProvider
Add your own custom provider?
Last updated