Documentation Index
Fetch the complete documentation index at: https://docs.toju.network/llms.txt
Use this file to discover all available pages before exploring further.
What is a CID?
A Content Identifier (CID) is a cryptographic hash that uniquely identifies content in IPFS. The same content always produces the same CID, enabling verifiable, immutable storage. Example:bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
Why CID Matters
In traditional cloud storage, you pay for space regardless of what you store. With the sdk, you pay for specific content identified by its CID. This creates a binding between your payment and your data.The Problem We’re Solving
Without binding payments to a specific CID, we’d run into issues like:- Upload without paying: Pin files to IPFS first, then never actually pay
- Pay once, upload many: Reuse a single payment for multiple different files
- Content substitution: Pay for one file, store something completely different
The Pin-First Approach
We pin files to IPFS before creating the on-chain deposit, making the CID a cryptographic commitment:How It Works
1. CID from IPFS
When you upload files, we pin them to IPFS and receive the authoritative CID back:- SHA-256 hashing
- dagPB codec (IPFS directory structure)
- UnixFS for file and directory representation
2. CID in Blockchain Deposit
The CID becomes part of your on-chain deposit:- Same user + same CID = same deposit account
- Different CID = different deposit account
- Can’t reuse deposits for different content
3. Payment Confirmed
Once the on-chain transaction is confirmed, we mark the upload active in our database. The CID is now permanently linked to your payment — accessible for the full duration you paid for.Benefits
Payment Integrity
Deposits are locked to specific content, preventing fraud
Content Verification
Server verifies uploaded content matches committed CID
Deterministic Accounts
Same content produces same on-chain deposit account
Renewal Capability
CID serves as stable identifier for storage renewals
Multi-File Uploads
For directories with multiple files, the sdk generates a root CID that represents all files:- Whole directory:
ipfs://{rootCID}/ - Individual file:
ipfs://{rootCID}/file1.jpg - File by its own CID:
ipfs://{fileCID}
Security Properties
Prevents Double-Spending
Prevents Content Substitution
Because we pin files to IPFS before building the deposit, the CID in the on-chain deposit is always exactly what was pinned. There’s no window to swap content after paying — the pin and the payment reference the same CID.Enables Renewals
Advanced Details
CID Format & Structure
CID Format & Structure
We use CIDv1 with base32 encoding:Breaking it down:
- b: base32 encoding
- afy: CID version 1
- bei…: SHA-256 hash of content
On-Chain Account Derivation
On-Chain Account Derivation
Deposit accounts are deterministically derived using:This creates an address that:
- Is unique per user per content
- Can be found without storing addresses
- Prevents duplicate deposits
Why Pin First?
Why Pin First?
Pinning before creating the deposit means the CID in the on-chain record is always the real IPFS CID — not a locally computed estimate that might differ from what the storage backend produces.Different IPFS implementations can produce different CIDs for the same content depending on chunk size, codec settings, and directory encoding. By pinning first and using the returned CID, we eliminate that mismatch entirely.
Learn More
IPFS CID Spec
Deep dive into content addressing
CAR Format
Content Addressable aRchive format
dagPB Codec
IPFS directory structure
Solana PDAs
Program Derived Addresses