Skip to content

Storage Providers

Engram relies on a provider implementing:

  • store(data, policy)
  • retrieve(cid)
  • renew(cid, policy)

Provider Selection

Use createProvider(name?) from @engram-sdk/providers.

ts
import { createProvider } from '@engram-sdk/providers'

const provider = await createProvider('synapse')

Supported names:

  • synapse (default)
  • storacha
  • mock

Synapse Provider

SynapseProvider targets Filecoin Onchain Cloud, supports replication hints, and handles deal submission for live usage.

Recommended for:

  • production storage
  • testnet integration validation
  • realistic spend and retrieval behavior

Typical live env:

bash
ENGRAM_STORAGE_PROVIDER=synapse
OPERATOR_PRIVATE_KEY=0x...
ENGRAM_NETWORK=calibration
SYNAPSE_WITH_CDN=false

Mock Provider

MockStorageProvider is deterministic and in-memory.

Recommended for:

  • unit tests
  • local development
  • CI pipelines without chain credentials

You can simulate slower storage behavior for tests:

bash
MOCK_LATENCY_MS=200

Storacha Provider

StorachaProvider is an IPFS-backed alternative and can be selected without changing app-level lifecycle code.

Required env:

bash
ENGRAM_STORAGE_PROVIDER=storacha
STORACHA_KEY=...
STORACHA_PROOF=...

Notes:

  • retrieval resolves through https://w3s.link/ipfs/<cid>
  • renew is a no-op in this provider implementation
  • useful for alternative persistence flows or integration experiments

Choosing a Provider Per Environment

EnvironmentProviderWhy
Unit testsmockfast, deterministic
Local app devmock or synapsechoose speed vs realism
Stagingsynapse on calibrationrealistic ops with low risk
Productionsynapse on mainnetpersistent and live

Released under the MIT License.