1

I'm building a Chess platform on Telegram MiniApp and in the browser as well. However, I have a question I would love to ask:

I was looking for Gasless Transactions (developers sponsoring gas fees for users) to interact with the platform, and I found an article stating that Circle has supported it https://www.circle.com/blog/how-circles-gas-station-uses-fee-payers-to-enable-gasless-transactions-on-solana.

Since I'm planning to build an on-chain Chess game, does it require users to sign a message for every move they make?

I would like to cover all the gas fees, send the moves to the blockchain, and have users not need to sign any messages to execute their transactions.

Here are the flows:

  1. Player A and B starts on-chain match (when users press "Play Game" button, the system automatically pay the gas fee when both players are matched)
  2. Play A and B makes their first moves (moves record > send to blockchain)
  3. Both users perspective won't see anything, just like a normal game like off-chain game (because all the moves have fee covered by dev)
  4. Finish the game (A checkmated B) -> it sends status of the match to the blockchain and update both users elo.

That's what I am expected when doing this project on Solana. I have coded something like this on EVM and hope Solana can support a method like this.

2 Answers 2

2

There are a few ways you could do this, a couple are:

  • Require user to log in with wallet signature, once logged in, use a traditional backend auth and a dummy Keypair encrypted in your backend to sign the generated transactions and send them, paying for the gas and any state changes. You'd need to be careful to rate limit and not allow unauthorized users do this.

  • Use MPC wallets for users that allow for temporary key storage. Several providers include DFNS and Turnkey allow for certain types of key caching, so a user signs once at the start of the session and not again after that. It would still be self-custodies but you could fund the MPC wallets with a small bit of SOL to get started. It'd probably be good to gate the creation of your accounts.

1
  • thanks for answering my question, ser. I'll take a look of those suggestion from yours.
    – Le Nguyen
    Commented Sep 25 at 13:04
1

Like Truitt said signing in the backend will probably work nicely.

If you dont want to have a centralized backend then what you can do is use the SessionKey feature by Magic Block. https://docs.magicblock.gg/Onboarding/Session%20Keys/how-do-session-keys-work

What this does is it creates a session similar to Web2 session that will be used to sign transactions on the behalf of the user for a certain amount of time.

You can easily set up an example game using session keys using the solana games preset:

npx create-solana-game gamename

It will create you a program with session keys and a js and a unity client.

This is the repository: https://github.com/solana-developers/solana-game-preset

Here is also an on chain chess example that you can use as inspiration. https://github.com/magicblock-labs/Solana-Unity-Chess/tree/f8ddb69219ff6b32af27e1297c39fb164d4b32cf

1
  • 1
    Thanks, right now. I'm in connection with the MagicBlock and they are helping me to explore the Magic Block as well. We might focus some on features that can be deployed on chain easily instead of doing full on-chain game right now. Thanks a lot, Jonas.
    – Le Nguyen
    Commented Sep 25 at 13:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.