Stellar PHP SDK API Documentation

TransferServerService

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
see
https://github.com/stellar/stellar-protocol/blob/v4.3.0/ecosystem/sep-0006.md

SEP-06 v4.3.0 Specification

see
https://github.com/stellar/stellar-protocol/blob/v3.4.1/ecosystem/sep-0010.md

SEP-10 v3.4.1 Authentication

see
https://github.com/stellar/stellar-protocol/blob/v1.15.0/ecosystem/sep-0012.md

SEP-12 v1.15.0 KYC API

see
https://github.com/stellar/stellar-protocol/blob/v2.5.0/ecosystem/sep-0038.md

SEP-38 v2.5.0 Quotes

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
throws
CustomerInformationNeededException

Anchor needs more customer information via SEP-12

throws
CustomerInformationStatusException

Customer information pending or rejected

throws
AuthenticationRequiredException

Endpoint requires authentication but no JWT provided

throws
GuzzleException

If request error occurs

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
throws
CustomerInformationNeededException

Anchor needs more customer information via SEP-12

throws
CustomerInformationStatusException

Customer information pending or rejected

throws
AuthenticationRequiredException

Endpoint requires authentication but no JWT provided

throws
GuzzleException

If request error occurs

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
throws
GuzzleException

If request error occurs

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
throws
Exception

If service address cannot be loaded from domain or TRANSFER_SERVER not defined

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
throws
GuzzleException

If request error occurs

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
throws
GuzzleException

If request error occurs

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
throws
GuzzleException

If request error occurs

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
throws
GuzzleException

If request error occurs

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
throws
CustomerInformationNeededException

Anchor needs more customer information via SEP-12

throws
CustomerInformationStatusException

Customer information pending or rejected

throws
AuthenticationRequiredException

Endpoint requires authentication but no JWT provided

throws
GuzzleException

If request error occurs

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
throws
CustomerInformationNeededException

Anchor needs more customer information via SEP-12

throws
CustomerInformationStatusException

Customer information pending or rejected

throws
AuthenticationRequiredException

Endpoint requires authentication but no JWT provided

throws
GuzzleException

If request error occurs

Return values
WithdrawResponse

Withdrawal instructions with quote information


        
On this page

Search results