Store IPFS data on peaq
This guide adds data to IPFS, writes the returned CID to peaq storage, and reads the data back through that CID.Connect to IPFS
This guide uses Helia, an IPFS implementation that runs without a full IPFS daemon and works in the browser as well as in Node. Install the two packages Helia needs:npm install helia- creates a Helia node.npm install @helia/unixfs- adds the unixfs filesystem on top of that node.
Retrieve data from the node
Read the data back with that CID:Connect to peaq
Install the two packages the chain connection needs:npm install @polkadot/api- websocket provider, API client, and the keyring used to sign the storage transaction.npm install @peaq-network/types- peaq’s type definitions.
Add the CID to peaq storage
Store the CID under an item type name:Build the storage key and retrieve the data
Install the two packages used to build the storage key:npm install @polkadot/util-crypto-decodeAddressandblake2AsHex.npm install @polkadot/util- byte and hex conversions.
Putting it all together
The full script:signAndSend without a status callback returns a transaction hash before inclusion. The fixed delay above is only a pause before reading. To wait for inclusion, use a signAndSend status callback, check dispatchError, and wait for status.isInBlock (or status.isFinalized for finality) before reading on-chain storage.
For more Helia usage, see the Helia examples.
