Tracking and Storing User Scores in a WebGL Unity Game Embedded in Telegram

I’m developing a Web3 project, which is a Unity game converted to WebGL and embedded in Telegram. The game is deployed on Bot-Feater.

At the end of each game session, the game displays the current score and high score to the user.

I want to implement a system that tracks the current player and rewards the top scorer on the leaderboard. Scores are stored in a backend like Firebase.

How can I:

  1. Save users’ scores in Firebase?
  2. Accurately track the user playing the game in Telegram?
  3. Store and retrieve scores efficiently for a WebGL game embedded in Telegram?

So to preface this I will mention that while there is a Firebase SDK for Unity, it does not export to webgl so in order to do this, you would likely need to use the Firebase JS SDK and then create bindings from your C# code to the JS.

From there you would want to authenticate users (in order to identify and very who is scoring what) and set up a database of scores and use security rules to bridge the authentication and scores.