I am currently working on P2E game. The game development is being underway in Unreal Engine 4. The users will play the game. And will achieve few tokens on behalf of their winnings. Let’s say I have a DAO P2E ERC20 Token named “Gold”. Each players Wining tokens are being save at the backend ( Database sql) along with the players addresses.
In general, Player will play the game, Win the match, The winning number of tokens along with the player address will be saved at the backend.
The problem I am facing right now, that How shall I create such a function that a user will simply Claim it’s tokens won from the match. I have created a contract and put some “Gold” tokens in that means I have formed a Pool from which the tokens will be transferred from Pool( contract) to user.
How a contract can verify that The person that is calling a function really have won x amount of $Gold tokens? How can I stop users that if they execute the functions directly from the etherscan so that It couldn’t be vulnerable to attack.
I have used several ways but it all kept failing. i have created API’s and fetched the data into the function of the particular user using Chainlink oracles that I got the problem that I can’t use msg.sender with the API link to get the particular player data.
I have tried Signature message still It doesn’t make sense that how could a contract would know that A person have actually won a particular amount.
Problem in a Nutshell:- I have ha P2E game, A user will play the game and will win ERC20 Tokens. The address and Amount will be saved in DB. Whenever player want to redeem the winning amount, it will simply click the button on the web page to redeem it’s winning. How can I transfer tokens from contract to User by validating that user have actually won x amount.