This repository demonstrates how to implement gasless transactions on Solana with Dynamic.
-
Install dependencies:
npm install
-
Create a
.env.localfile with your fee payer wallet's private key:FEE_PAYER_PRIVATE_KEY=your_private_key_here NEXT_PUBLIC_RPC=https://api.devnet.solana.com⚠️ WARNING: Never commit your private key to a repository or share it publicly. -
Run the development server:
npm run dev
-
Open http://localhost:3000 in your browser to see the application.
- The client sends transaction details to the server
- The server creates and partially signs the transaction, setting itself as the fee payer
- The client receives the partially signed transaction
- The user signs the transaction with their wallet
- The transaction is submitted to the Solana network with fees paid by the server wallet
/app/api/gas/route.ts- API endpoint that prepares and partially signs transactions/app/components/Send.tsx- Frontend component for initiating transfers/app/page.tsx- Main application page incorporating Dynamic authentication
For a detailed explanation of how this works, check out our comprehensive guide on implementing gasless transactions on Solana.