Interface Strings

The Strings interface provides a simple and intuitive way to add/get strings with your Helia node and is a great place to start learning about IPFS.

interface Strings {
    add(str, options?): Promise<CID<unknown, number, number, Version>>;
    get(cid, options?): Promise<string>;
}

Methods

Methods

  • Add a string to your Helia node and get a CID that refers to the block the string has been stored as.

    Parameters

    Returns Promise<CID<unknown, number, number, Version>>

    Example

    import { strings } from '@helia/strings'

    const str = strings(helia)
    const cid = await str.add('hello world')

    console.info(cid)
    // CID(bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e)
  • Get a string from your Helia node, either previously added to it or to another node on the network.

    Parameters

    Returns Promise<string>

    Example

    import { strings } from '@helia/strings'
    import { CID } from 'multiformats/cid'

    const str = strings(helia)
    const cid = CID.parse('bafkreifzjut3te2nhyekklss27nh3k72ysco7y32koao5eei66wof36n5e')
    const string = await str.get(cid)

    console.info(string)
    // hello world

Generated using TypeDoc