Helia
    Preparing search index...

    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: string,
            options?: Partial<AddOptions>,
        ): Promise<CID<unknown, number, number, Version>>;
        get(cid: CID, options?: Partial<GetOptions>): Promise<string>;
    }
    Index

    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>>

      import { createHelia } from 'helia'
      import { strings } from '@helia/strings'

      const helia = wait createHelia()
      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>

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

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

      console.info(string)
      // hello world