Skip to content

TypeScript SDK

The TypeScript SDK gives you typed, programmatic access to OpenTusk. Zero dependencies — uses native fetch.

  1. Install

    Terminal window
    npm install @opentusk/sdk
  2. Upload a file

    import { OpenTuskClient } from '@opentusk/sdk';
    import { readFile } from 'fs/promises';
    const opentusk = new OpenTuskClient({ apiKey: 'otk_your_key' });
    // List vaults
    const vaults = await opentusk.vaults.list();
    console.log(vaults);
    // Upload to your default vault
    const data = await readFile('./report.pdf');
    const file = await opentusk.files.upload({
    name: 'report.pdf',
    mimeType: 'application/pdf',
    vaultId: vaults[0].id,
    data,
    });
    console.log(file.status); // "hot"
  3. Wait for Walrus sync (optional)

    await opentusk.files.waitForStatus(file.id, ['synced'], {
    timeout: 120000,
    });
    console.log('File durably stored on Walrus');

Your file is hot — stored in a fast cache and immediately downloadable. In the background, OpenTusk syncs it to the Walrus decentralized network for durability.

uploading → hot → synced → cold
↑ durable on Walrus