AccountDataResponse class
Represents a data entry attached to a Stellar account.
Account data entries allow storing arbitrary key-value pairs on-chain. Each account can have up to 1000 data entries, with keys up to 64 bytes and values up to 64 bytes. Data entries are commonly used for:
- Domain verification (stellar.toml validation)
- Application-specific state storage
- On-chain configuration and metadata
- Managing arbitrary binary or text data
Values are stored and returned as base64-encoded strings. The SDK provides helper methods to decode values as bytes or UTF-8 strings.
Example - Querying and decoding account data:
// Query a specific data entry by key
var dataResponse = await sdk.accounts.data(
accountId: 'GCDNJUBQSX7AJWLJACMJ7I4BC3Z47BQUTMHEICZLE6MU4KQBRYG5JY6B',
key: 'config',
);
// Decode as UTF-8 string (throws if not valid UTF-8)
String textValue = dataResponse.decodedString;
print('Config value: $textValue');
// Safely decode as string (returns null if not valid UTF-8)
String? safeValue = dataResponse.decodedStringOrNull;
if (safeValue != null) {
print('Text data: $safeValue');
} else {
print('Binary data detected');
}
// Get raw bytes for binary data
Uint8List bytes = dataResponse.decodedValue;
print('Data size: ${bytes.length} bytes');
Example - Creating and updating data entries:
// Create a data entry with text value
var transaction = TransactionBuilder(sourceAccount)
.addOperation(
ManageDataOperationBuilder('app.version', '1.0.0').build(),
)
.build();
// Create a data entry with binary data
var binaryData = Uint8List.fromList([0x48, 0x65, 0x6C, 0x6C, 0x6F]);
var transaction2 = TransactionBuilder(sourceAccount)
.addOperation(
ManageDataOperationBuilder.forData('binary.data', binaryData).build(),
)
.build();
// Delete a data entry (set value to null)
var transaction3 = TransactionBuilder(sourceAccount)
.addOperation(
ManageDataOperationBuilder('old.key', null).build(),
)
.build();
Example - Domain verification:
// Check if account has home_domain data entry
try {
var domainData = await sdk.accounts.data(
accountId: accountId,
key: 'home_domain',
);
String domain = domainData.decodedString;
print('Account home domain: $domain');
} catch (e) {
print('No home_domain set for this account');
}
See also:
- AccountResponse for full account details including all data entries
- ManageDataOperation for creating/updating data entries
- Stellar developer docs
Constructors
- AccountDataResponse(String value)
- Creates an AccountDataResponse from Horizon API data.
-
AccountDataResponse.fromJson(Map<
String, dynamic> json) -
factory
Properties
- decodedString → String
-
Gets the decoded value as a UTF-8 string
Throws if the value is not valid UTF-8
no setter
- decodedStringOrNull → String?
-
Attempts to get the decoded value as a UTF-8 string
Returns null if the value is not valid UTF-8
no setter
- decodedValue → Uint8List
-
Gets the decoded raw value as bytes
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- rateLimitLimit ↔ int?
-
Maximum number of requests allowed in the current rate limit window.
getter/setter pairinherited
- rateLimitRemaining ↔ int?
-
Number of requests remaining in the current rate limit window.
getter/setter pairinherited
- rateLimitReset ↔ int?
-
Unix timestamp when the rate limit window will reset.
getter/setter pairinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → String
-
The base64 encoded value of the data entry
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
setHeaders(
Map< String, String> headers) → void -
Populates rate limit fields from HTTP response headers.
inherited
-
toJson(
) → Map< String, dynamic> - Converts this account data response to a JSON map.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited