[SOLVED] Should I save Streams txns to database?

I’m trying to setup Streams API with Supabase. I’m looking for mint and transfer events from a couple NFT contracts. I want to update user assets (saved to database) based on changes from the stream.

I see in the Firebase docs that it saves transactions to the database. Is this the recommended method rather than just dealing with txns as they come in?

Does it make sense to just save txns to a DB table (maybe with a column named ā€œprocessedā€ == true/false) then have a background process that goes row by row and check txns that are ā€œprocessedā€ === false and update the user corresponding users items.

This way I don’t miss incoming txns and I can see what data wasn’t processed?

Hi @jins

Saving in the database makes it easy to use and retrieve data at a later time. Since you only get steam once it is better to save it in db. It also helps to monitor if a transaction with confirmed: true is received.
You can process the data on your backend or in client app based on your usecase or whichever is effective.

1 Like

Yes makes sense. I don’t think I’ll need the data long term so I can just setup a cron job to delete anything older than a week.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.