Skip to main content
Version: Canary 🚧

How to auto approve transactions

Auto approving transactions means that the user does not have to manually confirm every transaction. This is especially useful for on-chain games where you want to have fluid game play. Here are some options on how this can be achieved.

Wallet Auto Approve

A few popular Solana wallet applications have transaction "auto approve" functionality directly with in them. Some accomplish this with burner wallets. This is a very convenient solution, but it may limit your players to using one of these wallets. Players may also be resistant to activate the feature since it may be seen as a security risk.

Local Keypair

Another way to add transaction auto approval is to create a keypair in your game/dApp and let the player transfer some SOL to that wallet and then use it to pay for transaction fees. The only problem with this is that you need to handle the security for this wallet and the keys can get lost if the users clear their browser cache.

Here, you can find some example source code on how to implement transaction auto approval using local keypairs:

Server Backend

Using a server backend for your game or dApp, you can configure a system that will allow your backend to handle paying the Solana fees yourself. This backend would allow you to create and sign transactions for the user, marking your secure backend keypair the fee payer, and enabling your application to interact with it via an API endpoint.

To accomplish this, your client application (i.e. game or dApp) would send parameters to your backend server. The backend server would then authenticate that request and the build a transaction with the required data from the user. The backend would then sign and send this transaction to the Solana blockchain, confirm the transaction was successful, and send a confirmation message to the client.

This server backend method is an easy and convenient solution, but you need to handle the user's authentication and security. So that could add complexity to your application's infrastructure and architecture.

Session Keys

Session Keys are ephemeral (short lived) keypairs with fine-grained program/instruction scoping for tiered access in your Solana programs. They allow users to interact with apps by signing transactions locally using a temporary keypair. The temporary keypair acts a bit like an oauth token from web 2, allowing access for a certain amount of time.

Session keys make for a really great user experience, but they do need some extra work to implement in the on-chain program. You can use the session-keys crate maintained by Magic Block using their official documentation.

Shadow Signer

Shadow signer is a feature within the Honeycomb Protocol that allows you to sign transactions.