URIScheme

public final class URIScheme : Sendable

Implements SEP-0007 - URI Scheme to Facilitate Delegated Signing.

This class provides functionality for creating and processing Stellar URIs that enable transaction signing delegation. Applications can generate URIs requesting users to sign transactions or make payments, and wallets can parse these URIs to fulfill the requests.

Typical Usage

let uriScheme = URIScheme()

// Generate payment URI
let paymentUri = uriScheme.getPayOperationURI(
    destination: "GDESTINATION...",
    amount: 100.50,
    assetCode: "USDC",
    assetIssuer: "GISSUER..."
)

// Generate transaction signing URI
let transaction = try Transaction(...)
let signingUri = uriScheme.getSignTransactionURI(
    transactionXDR: transaction.transactionXDR,
    callBack: "url:https://callback.example.com"
)

See also:

  • Undocumented

    Declaration

    Swift

    public init()
  • Generates a SEP-0007 compliant URI to request transaction signing.

    All parameter values are URL-encoded automatically.

    See: SEP-0007 tx operation

    Declaration

    Swift

    public func getSignTransactionURI(transactionXDR: TransactionXDR,
                                      replace: String? = nil,
                                      callBack: String? = nil,
                                      publicKey: String? = nil,
                                      chain: String? = nil,
                                      message: String? = nil,
                                      networkPassphrase: String? = nil,
                                      originDomain: String? = nil,
                                      signature: String? = nil) -> String

    Parameters

    transactionXDR

    A TransactionXDR object representing a transaction on the Stellar network

    replace

    Optional value identifying fields to be replaced in the XDR using Txrep (SEP-0011) representation

    callBack

    Optional URL callback where the signed transactionXDR will be sent (must be prefixed with “url:”)

    publicKey

    Optional public key that will be used to sign the transaction

    chain

    Optional SEP-0007 request that spawned or triggered the creation of this request

    message

    Optional message to display to the user in their wallet (max 300 characters)

    networkPassphrase

    Optional network passphrase, only needed for non-public networks

    originDomain

    Optional fully qualified domain name specifying the originating domain of the URI request

    signature

    Optional signature of the hash of the URI request (excluding the signature field itself)

    Return Value

    A SEP-0007 compliant URI string for the transaction signing request

  • Generates a SEP-0007 compliant URI to request a payment to a specific address.

    All parameter values are URL-encoded automatically. For MEMO_HASH or MEMO_RETURN memo types, the memo is base64-encoded before URL encoding.

    See: SEP-0007 pay operation

    Declaration

    Swift

    public func getPayOperationURI(destination: String,
                                   amount: Decimal? = nil,
                                   assetCode: String? = nil,
                                   assetIssuer: String? = nil,
                                   memo: String? = nil,
                                   memoType: String? = MemoTypeAsString.TEXT,
                                   callBack: String? = nil,
                                   message: String? = nil,
                                   networkPassphrase: String? = nil,
                                   originDomain: String? = nil,
                                   signature: String? = nil) -> String

    Parameters

    destination

    A valid account ID or payment address for the payment destination

    amount

    Optional amount that the destination will receive

    assetCode

    Optional asset code the destination will receive (defaults to XLM if not present)

    assetIssuer

    Optional account ID of the asset issuer (required for non-native assets)

    memo

    Optional memo to include in the payment

    memoType

    Optional memo type: MEMO_TEXT, MEMO_ID, MEMO_HASH, or MEMO_RETURN (defaults to TEXT)

    callBack

    Optional URL callback where the signed transactionXDR will be sent (must be prefixed with “url:”)

    message

    Optional message to display to the user in their wallet (max 300 characters)

    networkPassphrase

    Optional network passphrase, only needed for non-public networks

    originDomain

    Optional fully qualified domain name specifying the originating domain of the URI request

    signature

    Optional signature of the hash of the URI request (excluding the signature field itself)

    Return Value

    A SEP-0007 compliant URI string for the payment request

  • Signs and submits a transaction from a SEP-0007 URI to the Stellar network.

    Parses the transaction from the URI, optionally confirms it via the callback, signs it with the provided key pair, and submits it to the network or callback URL.

    Declaration

    Swift

    public func signAndSubmitTransaction(forURL url: String,
                                         signerKeyPair keyPair: KeyPair,
                                         network: Network = .public,
                                         transactionConfirmation: TransactionConfirmationClosure? = nil) async -> SubmitTransactionEnum

    Parameters

    url

    A SEP-0007 compliant URL containing the transaction to sign

    keyPair

    The KeyPair of the signer account

    network

    The Stellar network to use (defaults to public)

    transactionConfirmation

    Optional closure to confirm the transaction before signing (return false to cancel)

    Return Value

    SubmitTransactionEnum indicating success, memo requirement, or failure

  • Extracts a parameter value from a SEP-0007 URI.

    Declaration

    Swift

    public func getValue(forParam param: SignTransactionParams, fromURL url: String) -> String?

    Parameters

    param

    The parameter to extract

    url

    The SEP-0007 URI to parse

    Return Value

    The parameter value if found, nil otherwise