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() -
getSignTransactionURI(transactionXDR:replace: callBack: publicKey: chain: message: networkPassphrase: originDomain: signature: ) Generates a SEP-0007 compliant URI to request transaction signing.
All parameter values are URL-encoded automatically.
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) -> StringParameters
transactionXDRA TransactionXDR object representing a transaction on the Stellar network
replaceOptional value identifying fields to be replaced in the XDR using Txrep (SEP-0011) representation
callBackOptional URL callback where the signed transactionXDR will be sent (must be prefixed with “url:”)
publicKeyOptional public key that will be used to sign the transaction
chainOptional SEP-0007 request that spawned or triggered the creation of this request
messageOptional message to display to the user in their wallet (max 300 characters)
networkPassphraseOptional network passphrase, only needed for non-public networks
originDomainOptional fully qualified domain name specifying the originating domain of the URI request
signatureOptional 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
-
getPayOperationURI(destination:amount: assetCode: assetIssuer: memo: memoType: callBack: message: networkPassphrase: originDomain: signature: ) 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.
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) -> StringParameters
destinationA valid account ID or payment address for the payment destination
amountOptional amount that the destination will receive
assetCodeOptional asset code the destination will receive (defaults to XLM if not present)
assetIssuerOptional account ID of the asset issuer (required for non-native assets)
memoOptional memo to include in the payment
memoTypeOptional memo type: MEMO_TEXT, MEMO_ID, MEMO_HASH, or MEMO_RETURN (defaults to TEXT)
callBackOptional URL callback where the signed transactionXDR will be sent (must be prefixed with “url:”)
messageOptional message to display to the user in their wallet (max 300 characters)
networkPassphraseOptional network passphrase, only needed for non-public networks
originDomainOptional fully qualified domain name specifying the originating domain of the URI request
signatureOptional 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 -> SubmitTransactionEnumParameters
urlA SEP-0007 compliant URL containing the transaction to sign
keyPairThe KeyPair of the signer account
networkThe Stellar network to use (defaults to public)
transactionConfirmationOptional 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
paramThe parameter to extract
urlThe SEP-0007 URI to parse
Return Value
The parameter value if found, nil otherwise
View on GitHub
Install in Dash