FederationResponse

data class FederationResponse(val stellarAddress: String? = null, val accountId: String, val memoType: String? = null, val memo: String? = null)

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, or hash. 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 integer

  • For hash: Base64-encoded 32-byte hash Important: This field is always a string, even when memoType is id. 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"
}

See also

Constructors

Link copied to clipboard
constructor(stellarAddress: String? = null, accountId: String, memoType: String? = null, memo: String? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The Stellar account ID (G... address) - required

Link copied to clipboard
val memo: String?

The memo value as a string (optional)

Link copied to clipboard

The type of memo required: text, id, or hash (optional)

Link copied to clipboard

The Stellar address that was resolved (optional)