0

How can i subscribe to the new pending transactions of polkadot by using substrate interface python

3
  • I don't think its possible to subscribe on it, but you can use polling. What is your use-case? Commented Sep 8, 2022 at 18:17
  • My usecase is that if someone has deposited some amount of dots how would I come to know that from a particular account an amount of dots has deposited in my account? Commented Sep 12, 2022 at 5:31
  • 1
    By subscribing to events. This should never be done through pending transactions, since they can be invalid or removed by a re-org. Commented Sep 12, 2022 at 13:06

2 Answers 2

1

I think what you mean is the author_pendingExtrinsics RPC call, so that would be something like:

result = substrate.rpc_request("author_pendingExtrinsics", [])
0

Another angle, I think it's difference in terminology here. What you probably mean by coming from Ethereum is that pending transactions are transactions that are not yet 'finalized` in Substrate.

Finalized means it can never ever change. In a POW chain you work with confirmations, which gives you some kind certainty, in Substrate you have finality and give you absolute certainty.

This is different than the 'pending extrinsics' in Substrate, which means extrinsics in the tx pool, not yet including in a block.

What you probably want to know is which extrinsics are not yet finalized. So you just retrieve the finalized block_number:

result = substrate.get_block_header(finalized_only=True)
finalized_block_number = result['header']['number']

And any extrinsic in block height higher than that is a pending (unfinalized) extrinsic.

1
  • Arjan you're almost right about the concept of pending transactions.My usecase is that if someone has deposited some amount of dots how would I come to know that from a particular account an amount of dots has deposited in my account? Commented Sep 12, 2022 at 5:25

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.