Skip to main content

Module sponsored

Module sponsored 

Source
Expand description

Sponsored transaction helpers.

This module provides high-level utilities for creating and managing sponsored (fee payer) transactions, where one account pays the gas fees on behalf of another account.

§Overview

Sponsored transactions allow a “fee payer” account to pay the gas fees for a transaction initiated by a different “sender” account. This is useful for:

  • Onboarding new users - Users without APT can still execute transactions
  • dApp subsidization - Applications can pay gas fees for their users
  • Gasless experiences - Create seamless UX without exposing gas costs

§Example

use aptos_sdk::transaction::{SponsoredTransactionBuilder, EntryFunction};

// Build a sponsored transaction
let fee_payer_txn = SponsoredTransactionBuilder::new()
    .sender(user_account.address())
    .sequence_number(0)
    .fee_payer(sponsor_account.address())
    .payload(payload)
    .chain_id(ChainId::testnet())
    .build()?;

// Sign with all parties
let signed = sign_sponsored_transaction(
    &fee_payer_txn,
    &user_account,
    &[],
    &sponsor_account,
)?;

Structs§

PartiallySigned
A partially signed sponsored transaction.
SponsoredTransactionBuilder
A builder for constructing sponsored (fee payer) transactions.

Traits§

Sponsor
Extension trait that adds sponsorship capabilities to accounts.

Functions§

sign_sponsored_transaction
Signs a sponsored (fee payer) transaction with all required signatures.
sponsor_transaction
Creates a simple sponsored transaction with minimal configuration.