getOwnedBlobs method
Query all Walrus Blob objects owned by owner.
Returns a list of {objectId, blobId, size, ...} maps parsed
from the on-chain Blob struct fields.
Uses suix_getOwnedObjects with a StructType filter for
<packageId>::blob::Blob.
Example:
final blobs = await client.getOwnedBlobs(owner: myAddress);
for (final blob in blobs) {
print('${blob['objectId']} → blobId=${blob['blobId']}');
}
Implementation
Future<List<Map<String, dynamic>>> getOwnedBlobs({
required String owner,
int limit = 50,
}) async {
final blobType = await getBlobType();
final results = <Map<String, dynamic>>[];
String? cursor;
do {
final page = await suiClient.getOwnedObjects(
owner,
options: SuiObjectDataOptions(showContent: true, showType: true),
filter: {'StructType': blobType},
limit: limit,
cursor: cursor,
);
for (final obj in page.data) {
final data = obj.data;
if (data == null) continue;
final content = data.content;
if (content == null) continue;
Map<String, dynamic>? fields;
if (content.fields is Map<String, dynamic>) {
fields = content.fields as Map<String, dynamic>;
}
if (fields != null) {
// The blob_id is stored as a u256 on-chain.
// Convert to URL-safe base64 for consistency.
final blobIdRaw = fields['blob_id'] ?? fields['blobId'];
String? blobIdBase64;
if (blobIdRaw is String) {
// Could be a decimal string or hex
final bigInt = BigInt.tryParse(blobIdRaw);
if (bigInt != null) {
blobIdBase64 = blobIdFromInt(bigInt);
} else {
blobIdBase64 = blobIdRaw;
}
} else if (blobIdRaw is int) {
blobIdBase64 = blobIdFromInt(BigInt.from(blobIdRaw));
}
results.add({
'objectId': data.objectId,
'blobId': blobIdBase64,
'size': fields['size'],
'erasureCodeType':
fields['erasure_code_type'] ?? fields['erasureCodeType'],
'certifiedEpoch':
fields['certified_epoch'] ?? fields['certifiedEpoch'],
'storedEpoch': fields['stored_epoch'] ?? fields['storedEpoch'],
'deletable': fields['deletable'],
});
}
}
cursor = page.hasNextPage ? page.nextCursor : null;
if (cursor != null && cursor.isEmpty) cursor = null;
} while (cursor != null);
return results;
}