An end-to-end TypeScript script that walks through the full DataHaven storage workflow against a running network and MSP backend.
This repo is designed to be used alongside the tutorial video and as a clean reference implementation for validating your setup when working with buckets, files, MSPs, and on-chain confirmations.
The script (src/index.ts) executes the full storage lifecycle:
- Check MSP backend health
- Create a bucket (on-chain)
- Verify the bucket exists on-chain
- Wait until the MSP backend/indexer recognizes the bucket
- Upload a file via the MSP backend
- Wait until the backend makes the file available
- Download the file
- Verify file integrity (original vs downloaded)
This covers both sides of the system:
- On-chain coordination (bucket creation, confirmations)
- Off-chain data transfer (upload/download via MSP backend)
- Node.js (LTS recommended)
- pnpm
└── datahaven-project/
├── README.md
├── package.json
├── pnpm-workspace.yaml
├── tsconfig.json
├── .env.example
└── src/
├── index.ts
├── config/
│ └── networks.ts
├── operations/
│ ├── bucketOperations.ts
│ └── fileOperations.ts
└── services/
├── clientService.ts
└── mspService.ts
pnpm installpnpm tsx src/index.ts!!! note Bucket names must be unique. If you run the script multiple times against the same network and MSP, bucket creation will fail because bucket names must be unique.
The script is intentionally split into small, focused modules:
src/services/clientService.ts- Creates and manages wallet client, public client, StorageHub client, Polkadot API client.src/services/mspService.ts- Fetches MSP backend information and methods.src/operations/bucketOperations.ts- Handles bucket creation, on-chain verification, and backend readiness checks.src/operations/fileOperations.ts- Handles file upload, download, confirmation waits, and integrity verification.