A one-screen iOS app that downloads files from deCDN on an
iPhone. It runs the deCDN client SDK (decdn-client)
natively: it finds the nodes that hold a blob, streams it from all of them at once, verifies
every byte against its BLAKE3 hash as it arrives, and pays per megabyte in USDC from a payment
pool. A sponsor funds that pool, so the phone holds no USDC and no wallet.
Enter a content hash and tap Download. The first time, a one-step check opens in an in-app browser; once you pass it the browser closes and the download starts. Finished files land in the app's Documents folder, which the Files app shows under On My iPhone > deCDN demo. Turn on Whole bundle and the hash names a bundle manifest instead: every file it lists lands under a folder of its own.
The Android demo is the same app on Android.
┌────────────── iOS app ──────────────┐
│ ContentView (SwiftUI) │ ┌────────────┐
│ hash, namespace ──────────────────┼─────▶│ onramp │ up.decdn.org: a capability for
│ │ C ABI ▲ progress │ │ │ the app's key, after a check
│ ▼ │ │ └────────────┘
│ libdecdn_ios.a (Rust) │ ┌────────────┐
│ decdn-client BundlePuller ────────┼─────▶│ deCDN nodes│ iroh QUIC, paid per MB
│ throwaway key + capability │ └────────────┘
│ │ │ ┌────────────┐
│ └────────────────────────────┼─────▶│ Arbitrum │ pool + registry reads
└─────────────────────────────────────┘ │ Sepolia │
└────────────┘
rust/src/lib.rsis the whole native side, behind the C interface ininclude/decdn.h. It drivesdecdn_client::bundle::BundlePullerwithFunding::Delegated, so discovery, payment, resume and verification all come from the SDK. A single file is a one-entry manifest built in code. ABundleObserverfeeds verified-byte counts to the UI.DownloadModel.swiftholds the screen's state. It gets an allowance throughOnramp.swift, runs the pull on a background task, and polls progress every 500 ms.- On Apple platforms iroh reads DNS from SystemConfiguration and
rustls-platform-verifierchecks TLS against the Security framework, so the Rust side needs no setup call. rust/Cargo.tomlpinslibcto 0.2.189. Version 0.2.190 limitsin6_ifreqand the routing socket constants to macOS, and iroh'snetdevandnetwatchneed them on iOS (shellrow/netdev#192).
- A Mac with Xcode, selected with
sudo xcode-select -s /Applications/Xcode.app - Rust.
rust/rust-toolchain.tomlpins 1.99 and the iOS targets, so rustup installs them on first build. - XcodeGen:
brew install xcodegen - For a device: an iPhone on iOS 17 or newer and an Apple ID signed in to Xcode
In the simulator:
./build.sh
xcrun simctl install booted build/Build/Products/Debug-iphonesimulator/DecdnDemo.app
xcrun simctl launch booted dev.decdn.demoOn an iPhone, with your team id from Xcode > Settings > Accounts:
DEVELOPMENT_TEAM=<team-id> ./build.sh devicethen install build/Build/Products/Debug-iphoneos/DecdnDemo.app from Xcode's Devices window,
or open the generated DecdnDemo.xcodeproj and press Run. A free Apple ID signs builds that
stay installed for 7 days.
./build.sh builds the Rust library for the device and the simulator, packs both into
Frameworks/DecdnFFI.xcframework, generates DecdnDemo.xcodeproj from
project.yml, and builds the app.
The app pays as a delegate of a sponsord gateway, the same
way its decdn.sh installer does:
- On first launch the app makes a random throwaway key and keeps it in its container. The key holds no funds.
- On Download with no allowance, the app shows the onramp's gate page,
https://up.decdn.org/fund?client=<address>, in an in-app browser. Passing the check there has the sponsor sign a capability for the app's key: the right to spend up to a cap from the sponsor's pool until an expiry. - Meanwhile the app polls
GET /v1/capability?client=<address>every 2 s. When the capability arrives, the browser closes and the download starts.
The allowance line on the screen shows the key and how long its capability lasts. A capability's terms are fixed once issued, so when one runs out or comes within about an hour of expiry, the app starts over with a fresh key and shows the check again. An interrupted download resumes under the new key without paying twice for the bytes it has.
| Field | What to enter |
|---|---|
| Content hash | The blob's BLAKE3 hash, hex, with or without b3: |
| Namespace | The publisher's namespace id. Empty sends none. |
| Save as | The file name, or the folder name for a bundle |
| Whole bundle | On when the hash is a bundle manifest |
The status line shows the phase (finding nodes, downloading, verifying), verified bytes against the total, and the current rate. Cancel stops the pull where it is; Download again resumes it.
A link can fill the form and start the download in one tap:
decdn-demo://download?hash=<hex>&ns=<namespace>&name=<file or folder>&bundle=1
bundle=1 marks a bundle manifest; name defaults to a generic one. In the simulator,
xcrun simctl openurl booted '<link>' opens it.
To try it, pull the Sintel 4K bundle (namespace 1, Whole
bundle on, about 4.2 GiB):
b3:87539fba0ee64b9f7814d50af89988b0e10f624340dd6e8477a0984c27eaab42
This is a demo of the SDK, not a product. It targets the Arbitrum Sepolia testnet, whose
contract addresses are built into rust/src/lib.rs, and builds for 64-bit ARM devices and Apple
silicon simulators. iOS suspends an app seconds after it leaves the screen, so the screen stays
on while a pull runs; after an interruption, Download again resumes from the bytes on disk.
Dual-licensed under either MIT or Apache-2.0, at your option.