TransferServerService
in package
Main service class for SEP-06 Transfer Server protocol implementation.
Implements SEP-06 Deposit and Withdrawal API for anchor integration. This service enables wallets and clients to facilitate fiat on/off ramps through deposit and withdrawal operations. Unlike SEP-24, SEP-06 provides more direct programmatic access without requiring interactive web flows, though it supports various deposit and withdrawal methods including bank transfers, cash, and crypto.
Provides endpoints for:
- Info: Query anchor capabilities and supported assets
- Deposit: Initiate deposits from external assets to Stellar
- Deposit Exchange: Initiate cross-asset deposits with quotes
- Withdraw: Initiate withdrawals from Stellar to external assets
- Withdraw Exchange: Initiate cross-asset withdrawals with quotes
- Fee: Query fee information for operations
- Transactions: Query transaction history
- Transaction: Query individual transaction status
- Patch Transaction: Update pending transaction information
Tags
Table of Contents
Methods
- __construct() : mixed
- Constructor.
- deposit() : DepositResponse
- Initiate deposit of external asset to Stellar network.
- depositExchange() : DepositResponse
- Initiate cross-asset deposit with currency conversion using SEP-38 quotes.
- fee() : FeeResponse
- Query fee information for deposit or withdrawal operations.
- fromDomain() : TransferServerService
- Constructs TransferServerService by discovering service URL from domain using SEP-01.
- info() : InfoResponse
- Query anchor capabilities and supported assets via info endpoint.
- patchTransaction() : ResponseInterface
- Update pending transaction with additional required information.
- transaction() : AnchorTransactionResponse
- Query individual transaction details and status.
- transactions() : AnchorTransactionsResponse
- Query transaction history for deposits and withdrawals.
- withdraw() : WithdrawResponse
- Initiate withdrawal from Stellar network to external asset.
- withdrawExchange() : WithdrawResponse
- Initiate cross-asset withdrawal with currency conversion using SEP-38 quotes.
Methods
__construct()
Constructor.
public
__construct(string $serviceAddress[, Client|null $httpClient = null ]) : mixed
Parameters
- $serviceAddress : string
-
Transfer server base URL from stellar.toml TRANSFER_SERVER field
- $httpClient : Client|null = null
-
Optional HTTP client for requests. If not provided, creates default client
deposit()
Initiate deposit of external asset to Stellar network.
public
deposit(DepositRequest $request) : DepositResponse
Initiates a deposit where the user sends an external asset (BTC via Bitcoin, USD via bank transfer, etc.) to an anchor-controlled address. The anchor then sends equivalent Stellar tokens (minus fees) to the user's Stellar account.
For cross-asset deposits with SEP-38 quote support, use depositExchange() instead. The response provides deposit instructions including destination addresses, memos, and any additional requirements.
Parameters
- $request : DepositRequest
-
Deposit request parameters including asset code and account
Tags
Return values
DepositResponse —Deposit instructions and transaction details
depositExchange()
Initiate cross-asset deposit with currency conversion using SEP-38 quotes.
public
depositExchange(DepositExchangeRequest $request) : DepositResponse
Enables deposits with currency conversion where the user sends one asset (e.g., BRL via bank transfer) and receives a different asset on Stellar (e.g., USDC). Requires anchor to support SEP-38 quotes for exchange rates.
The response provides deposit instructions and quote details for the conversion. Use the quote_id from a prior SEP-38 quote request to lock in exchange rates.
Parameters
- $request : DepositExchangeRequest
-
Deposit exchange request with source and destination assets
Tags
Return values
DepositResponse —Deposit instructions with quote information
fee()
Query fee information for deposit or withdrawal operations.
public
fee(FeeRequest $request) : FeeResponse
Allows wallets to query the fee that would be charged for a given operation. Important when fee schedules are complex and cannot be fully expressed in the info endpoint's fee_fixed, fee_percent, or fee_minimum fields.
Parameters
- $request : FeeRequest
-
Fee request with operation type, asset, and amount
Tags
Return values
FeeResponse —Fee amount and details
fromDomain()
Constructs TransferServerService by discovering service URL from domain using SEP-01.
public
static fromDomain(string $domain[, Client|null $httpClient = null ]) : TransferServerService
Fetches the stellar.toml file from the domain and extracts the TRANSFER_SERVER URL.
Parameters
- $domain : string
-
Domain to query (e.g. 'testanchor.stellar.org')
- $httpClient : Client|null = null
-
Optional HTTP client for requests. If not provided, creates default client
Tags
Return values
TransferServerService —Constructed service instance
info()
Query anchor capabilities and supported assets via info endpoint.
public
info([string|null $jwt = null ][, string|null $language = null ]) : InfoResponse
Returns information about supported assets, deposit/withdrawal methods, fees, and feature flags. This is the discovery endpoint that clients should query first to understand what operations the anchor supports.
Parameters
- $jwt : string|null = null
-
Optional SEP-10 JWT token from authentication flow
- $language : string|null = null
-
Optional language code (RFC 4646). Defaults to 'en'. Error fields use this language
Tags
Return values
InfoResponse —Parsed response containing anchor capabilities
patchTransaction()
Update pending transaction with additional required information.
public
patchTransaction(PatchTransactionRequest $request) : ResponseInterface
Updates transaction details when the anchor requests more information via the pending_transaction_info_update status. The transaction's required_info_updates field specifies which fields need updating.
Should only be called when anchor explicitly requests updates. Attempting to update when no information is requested will result in an error.
Parameters
- $request : PatchTransactionRequest
-
Transaction ID and fields to update
Tags
Return values
ResponseInterface —Raw HTTP response
transaction()
Query individual transaction details and status.
public
transaction(AnchorTransactionRequest $request) : AnchorTransactionResponse
Retrieves detailed information about a specific transaction using one of: transaction ID, Stellar transaction hash, or external transaction ID.
Useful for validating transaction status and getting real-time updates on deposit or withdrawal progress.
Parameters
- $request : AnchorTransactionRequest
-
Transaction query with at least one identifier
Tags
Return values
AnchorTransactionResponse —Detailed transaction information
transactions()
Query transaction history for deposits and withdrawals.
public
transactions(AnchorTransactionsRequest $request) : AnchorTransactionsResponse
Retrieves transaction history for the authenticated account, enabling wallets to display status updates and historical records. Only returns deposit and withdrawal transactions processed through this anchor.
Supports filtering by asset, transaction kind, and time range, plus pagination for large result sets.
Parameters
- $request : AnchorTransactionsRequest
-
Transactions query parameters with filters and pagination
Tags
Return values
AnchorTransactionsResponse —List of matching transactions
withdraw()
Initiate withdrawal from Stellar network to external asset.
public
withdraw(WithdrawRequest $request) : WithdrawResponse
Initiates a withdrawal where the user redeems Stellar assets for their off-chain equivalent via the anchor. For example, redeeming NGNT tokens for fiat NGN sent to a bank account.
For cross-asset withdrawals with SEP-38 quote support, use withdrawExchange() instead. The response provides withdrawal instructions including the anchor's Stellar account, memo requirements, and any additional user information needed.
Parameters
- $request : WithdrawRequest
-
Withdrawal request parameters including asset code and type
Tags
Return values
WithdrawResponse —Withdrawal instructions and transaction details
withdrawExchange()
Initiate cross-asset withdrawal with currency conversion using SEP-38 quotes.
public
withdrawExchange(WithdrawExchangeRequest $request) : WithdrawResponse
Enables withdrawals with currency conversion where the user sends one Stellar asset (e.g., USDC) and receives a different off-chain asset (e.g., NGN to bank account). Requires anchor to support SEP-38 quotes for exchange rates.
The response provides withdrawal instructions and quote details for the conversion. Use the quote_id from a prior SEP-38 quote request to lock in exchange rates.
Parameters
- $request : WithdrawExchangeRequest
-
Withdrawal exchange request with source and destination assets
Tags
Return values
WithdrawResponse —Withdrawal instructions with quote information