Footprint

public final class Footprint : Sendable

Ledger footprint wrapper for Soroban transaction simulation.

A footprint represents the set of ledger entries that a Soroban transaction will read from or write to during execution. Footprints are returned when simulating transactions and must be included in the final transaction to ensure resource limits are properly calculated.

The footprint contains two categories of ledger keys:

  • Read-only: Entries the transaction will read but not modify
  • Read-write: Entries the transaction will read and potentially modify

This class provides utility methods to:

  • Parse footprints from base64-encoded XDR
  • Extract specific ledger keys (contract code, contract data)
  • Convert footprints to XDR format for transaction submission

Example:

// Parse footprint from simulation response
let footprint = try Footprint(fromBase64: simulationResponse.footprint)

// Extract contract code ledger key
if let codeKey = footprint.contractCodeLedgerKey {
    print("Contract code key: \(codeKey)")
}

// Create empty footprint
let emptyFootprint = Footprint.empty()

See also:

  • [SimulateTransactionResponse] for simulation results
  • SorobanTransactionDataXDR for transaction resource configuration
  • Stellar developer docs
  • The underlying XDR footprint containing read-only and read-write ledger keys.

    Declaration

    Swift

    public let xdrFootprint: LedgerFootprintXDR
  • Creates a footprint from an XDR footprint object.

    Declaration

    Swift

    public init(xdrFootprint: LedgerFootprintXDR)

    Parameters

    xdrFootprint

    The XDR representation of the ledger footprint

  • Creates a footprint by decoding base64-encoded XDR.

    Throws

    XDR decoding errors if the input is invalid

    Declaration

    Swift

    public init(fromBase64 xdr: String) throws

    Parameters

    xdr

    Base64-encoded XDR string representing a LedgerFootprintXDR

  • Creates an empty footprint with no read-only or read-write entries.

    Declaration

    Swift

    public static func empty() -> Footprint

    Return Value

    A new Footprint instance with empty ledger key arrays

  • The footprint encoded as a base64 XDR string.

    Use this to include the footprint in transaction submission.

    Declaration

    Swift

    public var xdrEncoded: String { get }
  • The first contract code ledger key found in the footprint, encoded as base64 XDR.

    Returns nil if no contract code entry exists in the footprint.

    Declaration

    Swift

    public var contractCodeLedgerKey: String? { get }
  • The first contract code ledger key found in the footprint as an XDR object.

    Searches both read-only and read-write entries for a LedgerEntryType.contractCode key. Returns nil if no contract code entry exists in the footprint.

    Declaration

    Swift

    public var contractCodeLedgerKeyXDR: LedgerKeyXDR? { get }
  • The first contract data ledger key found in the footprint, encoded as base64 XDR.

    Returns nil if no contract data entry exists in the footprint.

    Declaration

    Swift

    public var contractDataLedgerKey: String? { get }
  • The first contract data ledger key found in the footprint as an XDR object.

    Searches both read-only and read-write entries for a LedgerEntryType.contractData key. Returns nil if no contract data entry exists in the footprint.

    Declaration

    Swift

    public var contractDataLedgerKeyXDR: LedgerKeyXDR? { get }