Bags
Files are organized into bags, each identified by a unique 256-bitBagID (the hash of the torrent info cell). A bag can contain a single file or a directory.
Files in a bag are split into 128 KiB chunks. A Merkle tree built from SHA-256 hashes allows verification of individual chunks without downloading the full bag. Bag metadata can be exported as a metafile.
Peer discovery
Nodes that store a bag register in the TON DHT under a key derived from theBagID. Clients query the DHT to find seeder addresses for a given bag.
Storage daemon
storage-daemon is the official implementation, distributed as part of the TON software suite. To start:
Manage bags
| Command | Description |
|---|---|
create <path> -d "description" | Create a new bag from a file or directory |
add-by-hash <hash> -d <dir> | Add a bag by its BagID |
add-by-meta <metafile> -d <dir> | Add a bag from a metafile |
list | List all bags |
list --hashes | List bags with their BagIDs |
get <BagID> | Show full bag information |
get-peers <BagID> | Show peers connected for a bag |
get-meta <BagID> <file> | Export the bag metafile |
download-pause <BagID> | Pause a download |
download-resume <BagID> | Resume a download |
priority-name <BagID> <name> <N> | Set download priority for a file (0 = skip, 255 = highest) |
--partial flag when adding:
Storage providers
A storage provider is a node that stores bags for a fee, backed by an on-chain smart contract. The provider system has two components:- Smart contract: deployed on the TON Blockchain, stores the Merkle tree hash of each bag, issues proof challenges, and manages client payments.
storage-daemon: runs on the provider’s machine, downloads bags, serves data to peers, and submits storage proofs to the contract.
Provider workflow
- The provider deploys a main smart contract and shares its address with clients.
- A client creates a bag and sends a storage request to the provider contract.
- The provider contract deploys a per-bag storage contract and notifies the client.
- The provider downloads the bag and activates the per-bag contract.
- The client transfers payment. The provider submits periodic Merkle proofs to prove data possession.
- When the client balance reaches zero or either party closes the contract, remaining funds return to the client and the contract self-destructs.
Integration with TON DNS
A.ton domain can point to a bag using the dns_storage_address record:
Ecosystem use cases
- NFT metadata: NFT collections can reference off-chain media and metadata stored as bags, using the
BagIDas a stable content identifier. Individual files within a bag are addressed using thetonstorage://<BagID>/pathURI scheme. - Static TON Sites: a bag containing HTML and static assets can be served as a TON Site by combining TON Storage, TON DNS, and TON Proxy.