Upload Lifecycle
Step-by-step breakdown of how files are uploaded and permanently stored via Cascade.
Overview
A Cascade upload consists of three phases: prepare, register, and send. The SDK's uploadFile method handles all three, but you can also run them individually for fine-grained control.
Phase 1: Prepare
- The input file (a
Uint8Array,File, orBlob) is converted to aUint8Array - A BLAKE3 hash is computed over the file bytes, this becomes the permanent content identifier stored on-chain
Phase 2: Register Action On-Chain
This phase involves multiple sub-steps:
2a. Fetch Action Parameters
The SDK queries the chain for current parameters:
These parameters determine the RaptorQ encoding configuration. Results are cached for 5 minutes.
2b. Generate RaptorQ Layout
The file is processed through the RaptorQ WASM module to generate an erasure-coding layout:
rq_ids_icis a random counter seed in[0, max_raptor_q_symbols)- The layout contains block-level encoding metadata that Supernodes need to store and reconstruct the file
- The layout JSON is compacted (no whitespace) to match the Go reference implementation
2c. Sign the Layout (ADR-036)
The compacted layout bytes are signed using ADR-036 signArbitrary:
This signature proves the layout was created by the account that registered the action.
2d. Derive Layout IDs
Layout IDs are deterministic identifiers derived from the layout and its signature. The algorithm must match the on-chain Go implementation exactly:
These IDs are included in the on-chain action and allow Supernodes to verify data integrity.
2e. Build LEP-1 Index File
The index file is signed with ADR-036 and included in the on-chain registration.
2f. Create Auth Signature
A separate signature over the dataHash is created this is used to authenticate the file upload to SN-API.
2g. Broadcast MsgRequestAction
The SDK simulates the transaction to estimate gas, then signs and broadcasts:
The chain validates the message, escrows fees, and emits an action_registered event. The SDK extracts the action_id from the event attributes.
Phase 3: Send File to Supernodes
- The file is sent as multipart form data to
POST /api/v1/actions/cascade: - The SN-API distributes chunks to the Supernode mesh
- The SDK polls
GET /api/v1/actions/cascade/tasks/{task_id}at the configured interval - Upload completes when the task reaches a terminal status
Unified Upload
For most use cases, call uploadFile to run all three phases:
Task States
| Status | Phase | Meaning |
|---|---|---|
sdk:completed | Upload | File successfully stored |
sdk:upload_completed | Upload | Upload confirmed |
sdk:failed | Upload | Generic failure |
sdk:supernodes_unavailable | Upload | No Supernodes accepted the task |
sdk:registration_failure | Register | On-chain registration failed |
sdk:upload_failed | Upload | File transfer to SN-API failed |
sdk:processing_failed | Upload | SN-API could not process the file |
sdk:processing_timeout | Upload | Processing exceeded timeout |
Retry Behavior
The SDK automatically retries the SN-API upload up to 5 times with a 3-second delay between attempts. This handles the case where the Supernode has not yet indexed the on-chain action (eventual consistency between chain and SN-API).