diff --git a/docs/subscriptions.rst b/docs/subscriptions.rst index 85a4f303cf..2dd4b23b6c 100644 --- a/docs/subscriptions.rst +++ b/docs/subscriptions.rst @@ -33,7 +33,8 @@ When you subscribe to an event – new block headers, for example – you'll rec print(response) # unsubscribe: - if response["number"] > 42012345: + new_head = response["result"] + if new_head["number"] > 42012345: await w3.eth.unsubscribe(subscription_id) break diff --git a/newsfragments/3850.docs.rst b/newsfragments/3850.docs.rst new file mode 100644 index 0000000000..46ef71fc5b --- /dev/null +++ b/newsfragments/3850.docs.rst @@ -0,0 +1 @@ +Fix the introductory subscription example to read the block number from the formatted subscription response result.