> For the complete documentation index, see [llms.txt](https://stratrosai.gitbook.io/stratrosai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://stratrosai.gitbook.io/stratrosai/whitepaper-of-stratrosai/da-service-api/icda-storage-canister-and-confirmation-canister/storage-canister.md).

# Storage Canister

The storage canister is responsible for K-V storage and retrieval of blobs.

## Canister Types

```rust
/// Storage Canister
// Canister Get Blob Types
struct Blob {
    data: Vec<u8>, // blob data
    next: Option<usize>, // next slice index: u64
}

/// Save Blob Argument
/// To manage subnet storage pressure, blobs are uploaded serially in slices.
struct BlobChunk {
    index: usize,          // Segmented upload index
    digest: [u8; 32],      // Sha256 digest of the blob in hex format
    timestamp: u128,       // Time since epoch in nanoseconds
    total: usize,          // Total blob size in bytes
    data: Vec<u8>,         // Blob slice (a piece of the Blob)
}

// Storage Canister Configuration
struct Config {
    signature_canister: Principal,      // Principal authorized to upload blobs
    owner: Principal,                   // Principal managing confirmations and signatures
    query_response_size: usize,         // Adjusted for efficient blob retrieval
    canister_storage_threshold: u32,   // Maximum blobs stored (7-day period recommended)
}

enum Result {
    Ok(),
    Err(String),
}
```

## Canister Services

```rust
// Retrieve the first slice of a Blob (if slicing is required, returns the first slice)
fn get_blob(digest: [u8; 32]) -> Blob {}

// Retrieve subsequent slices of a Blob by index
fn get_blob_with_index(digest: [u8; 32], index: usize) -> Blob {}

// Save a Blob slice
fn save_blob(chunk: BlobChunk) -> Result<(), String> {}
```

## Candid Interfaces

```
type Blob = record { data : blob; next : opt nat64 };
type BlobChunk = record {
  total : nat64;
  data : blob;
  timestamp : nat;
  digest : blob;
  index : nat64;
};
type Config = record {
  owner : vec principal;
  signature_canister : principal;
  query_response_size : nat64;
  chunk_size : nat64;
  canister_storage_threshold : nat32;
};
type Result = variant { Ok; Err : text };
service : {
  get_blob : (blob) -> (Blob) query;
  get_blob_with_index : (blob, nat64) -> (Blob) query;
  notify_generate_confirmation : (blob) -> ();
  save_blob : (BlobChunk) -> (Result);
  update_config : (Config) -> ();
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://stratrosai.gitbook.io/stratrosai/whitepaper-of-stratrosai/da-service-api/icda-storage-canister-and-confirmation-canister/storage-canister.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
