Add an object to your Helia node and get a CID that refers to the block the object has been stored as.
Optional
options: Partial<AddOptions>import { dagCbor } from '@helia/dag-cbor'
const d = dagCbor(helia)
const cid = await d.add({ hello: 'world' })
console.info(cid)
// CID(bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae)
Get an object from your Helia node, either previously added to it or to another node on the network.
Optional
options: Partial<GetOptions>import { createHelia } from 'helia'
import { dagCbor } from '@helia/dag-cbor'
import { CID } from 'multiformats/cid'
const helia = await createHelia()
const d = dagCbor(helia)
const cid = CID.parse('bafyreidykglsfhoixmivffc5uwhcgshx4j465xwqntbmu43nb2dzqwfvae')
const obj = await d.get(cid)
console.info(obj)
// { hello: 'world' }
The JSON interface provides a simple and intuitive way to add/get objects with your Helia node and is a great place to start learning about IPFS.