Reputation: 2180
I am looking into possibility of using Smart Contracts in our Casino. Because we don't want to have the players pay the fee for every hand they play, we want to use "view" transactions that don't modify the state and thus don't require any gas. This, however, introduces the following problem: "Since the transaction isn't saved on the blockchain, it is hard (or impossible?) to prove to someone that you really called the smart contract function (and that you called it only once).
One option that I thought about was to have the client(browser) call the function on smart contract. However, since our backend also needs to "know" the result, the player can, of course, change the result on his end, and send the wrong result.
If, on the other hand, we have our backend call the function on smart contract, there should be a way to prove to the player that we really called the smart contract and that we called it just once. I find it hard to do that.
One idea was to call the smart contract from client, encrypt the data using public key and send it to the backend so it can decrypt them and see the result. However, the player wouldn't know if the server really used this data, and I'm not even sure if encrypting with public key has any sense, since the execution of the smart contract function is public, so I guess everyone would know the input.
So, my question is, is there a way to convince the player that we really called the smart contract and that we called it just once?
EDIT: One other idea that came to my mind is to use one private/public key pair per game session, so that in the end of the session the player finds out the private key and if we store the history of all bet results on the client, the player can check if those were real results using the private key he got.
There is still a question if a player would see the bet result before it got encrypted on the smart contract
Upvotes: 0
Views: 1149
Reputation: 7380
Upvotes: 0
Reputation: 83566
Is there a way to convince the player that we really called the smart contract and that we called it just once?
The player can sign a message in their wallet and then your server calls the smart contract with this message. The smart contract decrypts the message and acts based on it. The transaction is pushed to the network by your server and the server has a hot wallet that covers ETH cost.
Alternatively, you can use a layer 2 network like Optimism where transaction costs are cheaper. You can also use Gas Station Network with relayers to make the user pay in a token instead of Ether.
Upvotes: 0