How Do You Sponsor Transactions with the Sui Gas Station?
The Sui Gas Station is a sponsored transaction mechanism that allows a third party to pay the gas fees for a user's transaction. Instead of the sender covering the Sui gas cost, a sponsor signs a separate sponsorship request that authorizes the network to deduct the fee from the sponsor's coin balance. The user constructs the transaction, the sponsor approves the gas payment, and both signatures are combined into a single programmable transaction block that the sponsor submits. The result is a transaction the user never pays for.
How sponsored transactions work on sui
Every transaction on Sui requires gas. Normally the sender's account must hold enough SUI to cover the computation and storage costs. With the gas station model, the transaction is split into two parts:
- User transaction: The actual operation the user wants to perform - transferring a coin, calling a Move function, or interacting with an object.
- Sponsorship request: A separate signature from the sponsor that authorizes the network to charge the gas fee to the sponsor's address instead.
The network validates both signatures. If the sponsor's account has sufficient SUI, the transaction executes and the gas cost is deducted from the sponsor's balance. The user's account never loses SUI.
When to Use a Gas Station
The pattern is useful in several real-world scenarios:
- Onboarding new users: A dApp can cover the first few transactions for a user who has no SUI yet, removing the friction of buying gas.
- Recurring operations: A game or subscription service can pay gas for automated actions on behalf of users.
- User experience: Wallet apps can hide gas costs entirely by sponsoring every transaction, though this requires the sponsor to fund the operation.
Gas stations are not a Sui-specific invention, but Sui's programmable transaction blocks make the implementation cleaner than on many other chains.
Setting up the sponsor
Before you can sponsor transactions, you need a Sui account that holds SUI and is willing to pay. This is typically a service account controlled by the dApp backend. The sponsor's private key must be kept secure, because anyone with that key can authorize gas payments.
You do not need to deploy a smart contract. Sponsorship is handled at the protocol level using the gas station API exposed by the Sui full node.
Step-by-Step: sponsoring a transaction
The following steps assume you are building a backend service in TypeScript or Rust using the Sui SDK. The exact method names depend on the SDK version, but the logic is consistent.
1. User constructs the transaction
The user builds a programmable transaction block (PTB) for whatever operation they want to perform. This PTB does not yet include any gas payment information.
const ptb = new TransactionBlock();
ptb.transferObjects([coinObjectId], recipientAddress);
The user signs this PTB with their own key and sends the signed transaction (but not the gas sponsorship) to the sponsor's backend.
2. Sponsor creates the gas sponsorship
The sponsor's backend receives the user's signed PTB. It then creates a separate GasSponsorship request. This request specifies:
- The gas budget (maximum SUI the sponsor is willing to pay)
- The gas price (from the current network reference gas price)
- The sponsor's gas coin object that will be used for payment
The sponsor signs this sponsorship request with their private key.
3. Sponsor combines both signatures
The sponsor merges the user's signature and the sponsorship signature into a single TransactionData structure. The Sui SDK provides a helper function for this, typically called combineTransactionSignatures or similar.
4. Sponsor submits the combined transaction
The sponsor executes the combined transaction via the Sui full node's executeTransactionBlock endpoint. The network checks:
- The user's signature is valid for the PTB.
- The sponsor's signature is valid for the gas sponsorship.
- The sponsor has enough SUI in the specified gas coin to cover the maximum budget.
If all checks pass, the transaction runs. The gas cost is deducted from the sponsor's coin, not the user's.
Gas budget and price considerations
The sponsor sets a gas budget. If the actual gas cost exceeds this budget, the transaction fails and the sponsor still pays for the computation that was already performed. Setting the budget too low causes unnecessary failures.
A common practice is to:
- Estimate the gas cost using the Sui dry-run API before sponsorship.
- Add a safety margin (e.g., 20% above the estimate) to absorb price fluctuations.
- Use the current reference gas price from the network, which you can query from the full node.
Security Notes
- Replay protection: Each sponsorship request includes a unique nonce derived from the user's PTB digest. The same sponsorship cannot be reused for a different transaction.
- Sponsor risk: The sponsor pays even for failed transactions. A malicious user could submit a transaction that intentionally fails after consuming significant gas. Sponsors should rate-limit users and set reasonable gas budgets.
- User trust: The user must trust the sponsor to actually submit the combined transaction. The user's signed PTB is useless on its own (it lacks gas), but the sponsor could theoretically modify the PTB before signing - though the user's signature binds the PTB content.
Alternative: Sui Gas Station as a Service
Instead of building your own sponsorship backend, you can use Sui's built-in gas station service available on testnet and mainnet. This service allows developers to request gas sponsorship through an API without managing a sponsor account. The service applies its own rate limits and gas budgets. Check the Sui documentation for current availability and endpoints.
Not financial advice. suiboxer.xyz publishes market data and general information about digital assets. Crypto assets are volatile and you can lose everything you put in. Nothing here is a recommendation to buy, sell or hold, and we make no price predictions.
Prices are sourced from third parties and may be delayed or wrong. Verify anything you intend to act on against a primary source.