ResourceConfig

public final class ResourceConfig : Sendable

Configuration for Soroban transaction resource calculation during simulation.

ResourceConfig allows you to adjust the instruction budget leeway used when simulating Soroban transactions. This affects how conservatively the system estimates the CPU instructions needed for transaction execution.

The instruction leeway is added as a safety margin to the actual instruction count observed during simulation. A higher leeway provides more buffer against edge cases but increases resource fees.

Use cases:

  • Increase leeway for transactions with variable execution paths
  • Reduce leeway for predictable operations to minimize fees
  • Adjust based on network conditions and fee tolerance

Example:

// Configure with 10% instruction leeway
let resourceConfig = ResourceConfig(instructionLeeway: 1000000)

// Use in transaction simulation
let request = SimulateTransactionRequest(
    transaction: transaction,
    resourceConfig: resourceConfig
)

let response = await server.simulateTransaction(request)

See also:

  • [SimulateTransactionRequest] for simulation configuration
  • [SorobanServer.simulateTransaction] for running simulations
  • Stellar developer docs
  • Instruction budget leeway used in preflight calculations.

    This value is added to the instruction count observed during simulation to provide a safety margin for actual execution. Specified in instruction units, where typical values range from 100,000 to several million depending on transaction complexity and desired safety margin.

    Declaration

    Swift

    public let instructionLeeway: Int
  • Creates a resource configuration with specified instruction leeway.

    Declaration

    Swift

    public init(instructionLeeway: Int)

    Parameters

    instructionLeeway

    Additional instructions to add as safety margin during simulation

  • Builds request parameters for Soroban RPC simulation requests.

    Converts the configuration into a dictionary suitable for JSON-RPC requests.

    Declaration

    Swift

    public func buildRequestParams() -> [String : Any]

    Return Value

    Dictionary containing the instructionLeeway parameter