Skip to main content

Recommended: JavaScript SDK for React Native

While this SDK is still supported, we recommend using newer JavaScript SDK, which is optimized for React Native, but also comes with a host of other benefits.
Looking for a simpler solution? If you’re using Dynamic’s embedded wallets, check out SVM Gas Sponsorship - a built-in feature that automatically sponsors gas fees with just a toggle in the dashboard.

Introduction

In this guide, we’ll show you how to create Solana transactions where a fee payer wallet pays the gas fees instead of your users. We achieve this by partially signing the transaction on the server and sending it to the client for final signing.

Getting Started

Setting up the Project

This walkthrough uses a Next.js app (React web SDK) so the UI and fee-payer API routes live in one repo. Create the project with create-next-app, then add @dynamic-labs/sdk-react-core and @dynamic-labs/solana with SolanaWalletConnectors in DynamicContextProvider. In the Dynamic dashboard, enable Solana under Chains & Networks and add your dev origin under SecurityAllowed Origins. For a native app without Next.js, start from the React Native Quickstart and adapt the API route pattern to your backend.

Setting Up the Fee Payer Wallet

You’ll need a wallet that will pay for gas fees on behalf of your users:
  1. Create a Solana wallet and add some funds to it (for paying gas fees)
  2. Add its private key (string format) to your .env.local file:
.env.local
Never share your private key or commit it to your code repository. Always use environment variables and add them to your .gitignore.

Server Implementation

Creating the API Route

Now we’ll create an API route that will prepare partially-signed transactions. Create a file at app/api/gas/route.ts:
app/api/gas/route.ts

How It Works

Our API route:
  1. Receives details about the transfer (who’s sending, receiving, and how much)
  2. Creates a transaction with the instructions
  3. Sets our server wallet as the fee payer
  4. Partially signs the transaction with the fee payer wallet
  5. Returns the transaction to the frontend

Client Implementation

Creating the Frontend Component

Now let’s create a simple UI for users to send tokens without paying gas. Create app/components/Send.tsx:
app/components/Send.tsx
For styling, create the Send.css file and you can find the styles we used here.

Using the Component

Finally, add the component to your main page in app/page.tsx:
app/page.tsx

Conclusion

Congratulations! You’ve successfully implemented gasless transactions on Solana using Dynamic’s SDK. This approach creates a superior user experience by allowing your users to perform transactions without worrying about gas fees.

Next Steps

Consider implementing rate limiting or additional verification to protect your fee payer wallet from abuse. To get the complete source code, check out our GitHub repository.
Last modified on July 24, 2026