Skip to content
Transaction requests enable interactive payment flows by allowing wallets to communicate with your server to compose any Solana transaction. This enables advanced use cases like NFT minting, dynamic pricing, multi-step DeFi transactions, and custom business logic.

​Overview

Transaction requests follow this URL format:
The wallet makes two HTTP requests to your endpoint:
  1. GET request - Retrieve payment information (label, icon)
  2. POST request - Get the transaction to sign
Examples on this page that use top-level await must run as ES modules. See Use ES Modules.

​Basic Setup

​1. Install Dependencies

​2. Create API Endpoint

Set up an API endpoint that handles both GET and POST requests:

​3. Create Payment URL

Generate the transaction request URL:

​Wallet-Side: Fetching Transaction Requests

On the wallet side, use fetchTransaction to retrieve and sign a transaction from a transaction request URL:

​Advanced Examples

​SPL Token Payment

Create a transaction for USDC payment:
The merchant’s USDC token account (merchantATA) must already exist, or the transfer fails with Invalid account data for instruction. Create it once before you accept payments (see Create a token account). To create it on demand instead, put a create instruction before the transfer. The buyer then pays the account’s rent the first time:

​Dynamic Pricing with Discounts

Implement dynamic pricing based on customer data:

​Order Management Integration

Integrate with your existing order system:

​Payment Validation

Validate completed transactions:

​Error Handling

Implement robust error handling:

​Best Practices

​Security

  • Validate all input parameters
  • Calculate amounts server-side only
  • Use HTTPS for all endpoints
  • Implement rate limiting
  • Store sensitive data securely

​Performance

  • Cache frequently accessed data
  • Use connection pooling
  • Implement request timeouts
  • Consider using webhooks for payment confirmation

​User Experience

  • Provide clear error messages
  • Show transaction progress
  • Handle network issues gracefully
  • Support transaction retries