Skip to main content
This guide covers how to use the Swig Paymaster SDK to sponsor transaction fees for your users, enabling gasless transactions.

What is a Paymaster?

A paymaster is a service that pays transaction fees on behalf of users, so they can begin using your application before acquiring SOL. Benefits:
  • Users can transact before acquiring SOL
  • Lower barrier to entry for new users
  • Better user experience for dApps

Prerequisites

Before using the paymaster SDK:
  1. Create a paymaster in the Developer Portal
  2. Fund your paymaster with SOL
  3. Get your API key from the Developer Portal
Paymasters require a paid subscription (PRO, ULTRA, or ENTERPRISE). See Subscriptions & Billing for details.

Installation

Choose the package that matches your Solana SDK version:
For applications using @solana/web3.js version 1.x (the traditional Solana SDK).

Configuration

Create a paymaster client with your credentials:

Configuration Options

Retry Options

Configure automatic retries for transient failures:

Quick Start

Here’s a minimal example to sponsor a transaction:

Transaction Flow

The paymaster transaction flow works as follows:
  1. Create Transaction: Build the transaction with the paymaster set as the fee payer
  2. User Signs: User signs to authorize the transaction
  3. Paymaster Signs: Paymaster validates and signs (covering the fee)
  4. Submit: Transaction is sent to the Solana network

Next Steps