1

I don't get any response from json-rpc subscription.

It seems I need a type paramater, but the provider.subscribe() method does not document the type parameter. (I checked the js, java and python code, can't find any explanation of this param).

const { WsProvider } = require('@polkadot/api');

(async () => {

  const provider = new WsProvider('wss://kusama-rpc.polkadot.io');
  var count = 0

  const type = '' // @param string <==== what should this be?
  const method = 'chain_subscribeAllHeads'
  // const method = 'subscribeAllHeads' // => method not found
  // const method = 'state_subscribeRuntimeVersion'
  const params = []

  const unsub = await provider.subscribe(type, method, params, (err, response) => {
    count++
    console.log(err, response)
    if(count > 2) {
      unsub()
      process.exit(0)
    }
  })
})()

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.