Polling NBA topshot events from flow

Hi there, I am new to Flow and currently I am trying to follow Eric Ren’s medium blog to poll NBA topshot purchase events from flow:

https://medium.com/@eric.ren_51534/polling-nba-top-shot-p2p-market-purchase-events-from-flow-blockchain-using-flow-go-sdk-3ec80119e75f

However, this part always gave me an error message:

blockEvents, err := flowClient.GetEventsForHeightRange(context.Background(), client.EventRangeQuery{
Type: “A.c1e4f4f4c4257510.Market.MomentPurchased”,
StartHeight: latestBlock.Height - 500,
EndHeight: latestBlock.Height,
})

panic: client: rpc error: code = InvalidArgument desc = requested block range (501) exceeded maximum (250)

If I changed the parameter from 500 to 200, then I did not get anything in return.

Can anyone help me out here?

Thanks a bunch!

1 Like

flow access nodes have had a limit of 250 blocks in one call for a while now because of performance reasons. You’ll have to implement sequential calls if you want to query more events

that is what I figured and thanks for confirming it. In future, where can I find these type of info? I did not see it in any flow doc or did I miss it?

I’m new to this, but my understanding is that what is returned by the above code from the Medium article might not return purchase events, and the subsequent code from the article filters out everything from the initial query:

for _, blockEvent := range blockEvents {
for _, purchaseEvent := range blockEvent.Events {
fmt.Println(purchaseEvent)
fmt.Println(purchaseEvent.Value)
}
}

I’d love to hear if you find a 250 block range where the results are not empty. Picking random 250 block ranges seems pretty random.

the market contract has been updated to V3, so i’m not sure if Market needs to be changed to MarketV3 in the initial code:

Type: “A.c1e4f4f4c4257510.Market.MomentPurchased”