# Sponsored Transactions

*[Documentation index](/llms.txt) · [Full index](/llms-full.txt)*

A transaction on Sui requires a gas payment to execute. The payment is a list of `0x2::coin::Coin<0x2::sui::SUI>` objects.

Sponsored transactions let you pay gas fees on behalf of another user. This reduces onboarding friction because users can execute transactions without owning SUI or understanding gas mechanics. As a sponsor, you provide the gas payment object for the transaction.

## Roles

A sponsored transaction involves three roles:

- **User:** The entity that wants to execute a transaction.

- **Gas station:** The service that provides gas payment objects for user transactions.

- **Sponsor:** The entity that funds the gas station.

The gas station and sponsor are often the same entity, but they differ when the sponsor uses a third-party gas station. For example, a Web3 gaming company might run its own gas station to offer free-to-play experiences during user acquisition. Alternatively, the company could use a third-party gas station service instead of maintaining its own.

## Data structure

The data structure of a sponsored transaction resembles the following:

```rust
pub struct SenderSignedTransaction {
    pub intent_message: IntentMessage<TransactionData>,
    /// A list of signatures signed by all transaction participants.
    /// 1. non participant signature must not be present.
    /// 2. signature order does not matter.
    pub tx_signatures: Vec<GenericSignature>,
}

pub struct TransactionDataV1 {  // <-- A variant of `TransactionData`
    pub kind: TransactionKind,  // <-- This is the actual transaction details
    pub sender: SuiAddress,
    pub gas_data: GasData,
    pub expiration: TransactionExpiration,
}

pub struct GasData {
    pub payment: Vec<ObjectRef>,
    pub owner: SuiAddress,
    pub price: u64,
    pub budget: u64,
}
```

A few details of note for the preceding code:

- `sender` in `TransactionDataV1` (a variant of `TransactionData`) is the user address.

- `gas_data` in `TransactionDataV1` is the gas payment.

- `GasData` allows a list of gas objects, but the same address must own them, namely the `owner` in `GasData` (the sponsor). When `owner` is equal to `sender`, then it is a regular or non-sponsored transaction.

- `tx_signatures` in `SenderSignedTransaction` is a list of signatures. For a sponsored transaction, the list needs to contain both signatures of the user and the sponsor in some order. The signatures are signed over the entire `TransactionData`, including `GasData`.

To construct a correct sponsored transaction, you must first build a `TransactionData` object. If you are neither the user or the sponsor, you pass the transaction to both parties to sign. If you're the sponsor, you sign the transaction and then pass it and the signature to the other party (in the form of `SenderSignedTransaction`) for them to sign. In practice, the latter is the more common scenario.

## Which sponsorship flow should I use?

Choose a flow based on who proposes the transaction and how much you restrict it:

| **Flow** | **Use it when** |
|---|---|
| [`GasData` object](#how-do-i-create-a-sponsored-transaction-using-a-gasdata-object) | You provide a `GasData` object and the user doesn't need to know the fee or approve it. |
| [User proposed transaction](#user-proposed-transaction) | The user proposes the transaction and you verify it's within your approved applications before providing gas payment. |
| [Sponsor proposed transaction](#sponsor-proposed-transaction) | You propose the transaction (such as a rewards claim or promotional offer) and the user decides whether to execute it. |
| [Wildcard gas payment](#what-is-wildcard-gas-payment) | You sponsor any valid transaction with few restrictions, such as for gasless wallets or rewards within a budget. |

## How do I create a sponsored transaction using a `GasData` object?

To use a `GasData` object to sponsor the gas fees for a transaction, create a `GasData` object that covers the fees determined for the transaction. The user doesn't need to know how much the fee is or approve it.

A sponsor transaction using a `GasData` object involves the following steps:

1. The sponsor provides a `GasData` object to a user.

1. The user constructs `TransactionData` and signs it to generate a `Signature`.

1. The user sends the `TransactionData` and the `Signature` to the sponsor.

1. The sponsor confirms the `TransactionData` and then signs it.

1. The sponsor submits the dual-signed `TransactionData` to a full node to execute the transaction.

### `GasLessTransactionData`

`GasLessTransactionData` is `TransactionData` without `GasData`. A user sends it to the sponsor so the sponsor can add `GasData` and construct the full `TransactionData` (see [User proposed transaction](#user-proposed-transaction)). It is not a `sui-core` data structure; it is only an interface between user and sponsor, so the following struct is an illustrative sketch rather than a type you import.

The following sketch shows the shape of a `GasLessTransactionData` object:

```rust
pub struct GasLessTransactionData {
    pub kind: TransactionKind,
    sender: SuiAddress,
    …
}
```

### User proposed transaction

You examine the transaction to verify it's within your approved applications before providing gas payment. For checks to apply, such as allowlisting `moveCall` targets and capping the gas budget, see [Production hardening](#production-hardening).

A user-proposed sponsored transaction involves the following steps:

1. A user initializes a `GasLessTransactionData` transaction.

1. The user sends `GasLessTransactionData` to the sponsor.

1. The sponsor validates the transaction, constructs `TransactionData` with gas fees, and then signs `TransactionData`.

1. The sponsor sends the signed `TransactionData` and the sponsor `Signature` back to the user.

1. The user verifies and then signs `TransactionData` and sends the dual-signed transaction to Sui network through a full node or the sponsor.

The following diagram shows the user-proposed flow. You can also [view the user-proposed sequence on swimlanes.io](https://swimlanes.io/d/wAcnOpA_h).

![User-proposed sponsored transaction sequence](./images/sequence_sponsor-txn-user-proposed_v1.png)

### Sponsor proposed transaction

You propose a transaction (such as a rewards claim or promotional offer) and the user decides whether to execute it. A sponsor proposed sponsored transaction involves the following steps:

1. A sponsor constructs a `TransactionData` object that contains the transaction details and associated gas fee data. The sponsor signs it to generate a `Signature` before sending it to a user. You can send unsigned `TransactionData` through email, SMS, or an application interface.

1. The user checks the transaction and signs it to generate the second `Signature` for the transaction.

1. The user submits the dual-signed transaction to a Sui full node or sponsor to execute it.

You can use a sponsor proposed transaction to propose rewards claims, promotional offers, or to incentivize specific user actions without requiring the user to pay for gas fees.

The following diagram shows the sponsor-proposed flow. You can also [view the sponsor-proposed sequence on swimlanes.io](https://swimlanes.io/#ZZE9T8QwDIb3/ApvLIWBsQMSEh8DEkI6mInb+O6itk4VOxInxH8nqe76AVki+X392G+iXnuq4fYGdmNgCRHeYhiDkIP3iCzYqg9syuGg2WmstWZMDYjG1Ora9YCK8G0gn2LoPLt6rb/kQjXLQuwo1rBL/t65SCKLdkD5dJlWwzNKwS4SfY0+YsFt2I9zuTI/047mEuj67pKthjmlHj13ki+CD6EIA56gIfCslFfRHN8zIOgyoQJkB2G/pyhZsefNLKDAiKeBWDczC7YG++d97EQ5264ExB8YNUUyZtpjbmyP1Hbb+cX7H7g0PqW+fw0uf5KkZvAKLmE/deU4K9Iv).

![Sponsor-proposed sponsored transaction sequence](./images/sequence_sponsor-txn-sponsor-proposed_v1.png)

### What is wildcard gas payment?

You sponsor any valid transaction with few restrictions.

- **Gasless wallets:** You agree to sponsor any valid transaction your users propose.

- **Rewards or discounts:** You offer a wildcard gas payment that executes any transaction within the budget.

The following diagram shows the wildcard flow. You can also [view the wildcard sequence on swimlanes.io](https://static.swimlanes.io/ee3962b3ac3cc5d34f317cecdde125b0.png).

![Wildcard gas payment sponsored transaction sequence](./images/sequence_sponsor-txn-wildcard_v1.png)

## Example API endpoints

The following Rust signatures sketch the endpoints a gas station might expose for each flow. They omit implementation bodies, so you implement them in your own service.

```rust
// User-initiated: receive GasLessTransactionData, return signed TransactionData
pub fn request_gas_and_signature(gasless_tx: GasLessTransactionData) -> Result<SenderSignedData, Error>;

// Wildcard: return a GasData object for the user
pub fn request_gas(/* requirements */) -> Result<GasData, Error>;

// Submit a single-signed transaction, sponsor signs and executes
pub fn submit_sole_signed_transaction(sole_signed_data: SenderSignedData) -> Result<(Transaction, CertifiedTransactionEffects), Error>;

// Submit a dual-signed transaction for execution
pub fn submit_dual_signed_transaction(dual_signed_data: SenderSignedData) -> Result<(Transaction, CertifiedTransactionEffects), Error>;
```

## What are the risks of sponsored transactions?

Sponsored transactions involve multiple parties, which introduces additional risks.

### Concurrent object use

Sponsored transactions still need valid, current object references for both the user's inputs and the sponsor's gas payment. If another inflight transaction already uses one of those same object versions, the sponsored transaction can be rejected and must be rebuilt or re-signed with updated references. If competing transactions split validator reservations, the object can be equivocated until the next epoch. Equivocation here means that conflicting transactions using the same object version each hold part of the validators' reservations, so the object cannot be used again until the next epoch.

Both the user and the sponsor can introduce this conflict:

- The user can reuse one of the transaction inputs in another inflight transaction.

- The sponsor can reuse the same gas object in another inflight sponsored transaction.

To reduce this risk:

- Sponsors should use dedicated gas coin pools and avoid reusing the same gas object in multiple inflight transactions.

- Clients should avoid signing multiple transactions that use the same owned object inputs.

- Both parties must sign the entire `TransactionData`, including `GasData`. This prevents a third party, such as a malicious full node, from intercepting partially signed data and changing the gas payment.

### Censorship

If you submit a dual-signed transaction through the sponsor or gas station rather than directly to a full node, the sponsor might delay or withhold the transaction from the network.

To avoid this risk, submit transactions directly to a full node.

## TypeScript example

The following example shows the complete sponsored transaction flow:

```typescript

const client = new SuiGrpcClient({
  baseUrl: 'https://fullnode.testnet.sui.io:443',
  network: 'testnet',
});
const user = new Ed25519Keypair();
const sponsor = new Ed25519Keypair();

// 1. User builds the transaction
const tx = new Transaction();
tx.setSender(user.toSuiAddress());
// Placeholder: replace 0xPACKAGE::module::function with your package ID, module, and function
tx.moveCall({ target: '0xPACKAGE::module::function' });

// 2. Sponsor sets gas payment
tx.setGasOwner(sponsor.toSuiAddress());
tx.setGasBudget(10_000_000);
// Placeholder: replace objectId, version, and digest with a SUI coin object owned by the sponsor
tx.setGasPayment([{ objectId: '0x...', version: '1', digest: '...' }]);

// 3. Build the transaction bytes
const bytes = await tx.build({ client });

// 4. Both parties sign
const userSig = await user.signTransaction(bytes);
const sponsorSig = await sponsor.signTransaction(bytes);

// 5. Submit with both signatures
const result = await client.executeTransaction({
  transaction: bytes,
  signatures: [userSig.signature, sponsorSig.signature],
});
```

:::info

Sponsorship is not the same as multi-sig. A sponsor pays gas but does not co-author the transaction intent. Multi-sig requires multiple parties to approve the same transaction. See [Multi-signature](/develop/transactions/transaction-auth/multisig) for details.

:::

## Production hardening

When you sponsor transactions in production, protect your gas budget from abuse:

- **Set per-user rate limits.** Track how many sponsored transactions each user address submits per time window (for example, 10 transactions per minute). Reject requests that exceed the limit. Without rate limiting, a single user can drain your gas balance.
- **Allowlist eligible transaction types.** Only sponsor transactions that match your expected patterns (for example, specific `moveCall` targets or transfer amounts). Reject unexpected transaction shapes before signing.
- **Cap the gas budget per transaction.** Set a maximum gas budget that your sponsor address signs for (for example, 50,000,000 MIST). Do not sponsor transactions with arbitrarily large gas budgets.
- **Monitor sponsored transaction volume.** Track daily gas spend, unique users, and transaction success rates. Set alerts when spend exceeds thresholds. Use the `gas_cost_summary` field in transaction effects to calculate actual costs ([Security Best Practices](/develop/security/best-practices)).
- **Use a dedicated sponsor address.** Do not sponsor from your main admin address. Create a separate address funded with a limited gas balance. Refill it periodically rather than holding a large balance.
- **Separate Testnet and Mainnet sponsors.** Use different sponsor addresses and rate limits per network to prevent Testnet testing from affecting production gas budgets ([Security Best Practices](/develop/security/best-practices)).

For more working examples including sponsored kiosk purchases and address-balance gas, see the [PTB Cookbook](/develop/transactions/ptbs/ptb-cookbook).
