Federation Response
Represents a successful response from a SEP-2 federation server.
The federation server returns this response when resolving a Stellar address to account information. This response maps user-friendly addresses (e.g., bob*stellar.org) to Stellar account IDs and optional memo information needed for payments.
Fields
stellarAddress: The Stellar address that was resolved (e.g.,
bob*stellar.org). This field is optional in the response but typically included for confirmation.accountId: Required. The Stellar account ID (public key) in G... format (e.g.,
GCIBUCGPOHWMMMFPFTDWBSVHQRT4DIBJ7AD6BZJYDITBK2LCVBYW7HUQ). This is the destination account for payments.memoType: Optional type of memo that should be attached to transactions sent to this account. Valid values are
text,id, orhash. If absent, no memo is required.memo: Optional value of the memo to attach to transactions. The format depends on memoType:
For
text: UTF-8 string (max 28 bytes)For
id: String representation of a 64-bit unsigned integerFor
hash: Base64-encoded 32-byte hash Important: This field is always a string, even when memoType isid. This ensures compatibility with languages that don't support 64-bit integers without precision loss.
Usage
val json = Json.parseToJsonElement(responseBody).jsonObject
val response = FederationResponse.fromJson(json)
println("Account ID: ${response.accountId}")
if (response.memoType != null && response.memo != null) {
println("Memo required: ${response.memoType} = ${response.memo}")
}Example Response
{
"stellar_address": "bob*stellar.org",
"account_id": "GCIBUCGPOHWMMMFPFTDWBSVHQRT4DIBJ7AD6BZJYDITBK2LCVBYW7HUQ",
"memo_type": "id",
"memo": "123"
}