IPFS in browser use case

I need to add create a following user scenario:

  1. User-A adds some data to ipfs from browser
  2. User-B gets a cid of the data from User-A via QR code
  3. User-B retrieves the data from IPFS.
    Am I right that it’s not possible to do this with just Helia?
    Where can I find any up-to-date working solution of any similar problem.
    I’ve already googled a lot, searched here and at github repos and quite frustrated…
    Thank you in advance!

What you are asking for is a subset of [🏆 Golden path scenario] Browser-authored content retrievable by another machine through the ipfs.io gateway directly · Issue #182 · ipfs/helia · GitHub
However your issue is way easier, so the way I would do it:

  • Enable / Be sure /webrtc listening is enabled (this will allow the browsers to talk to each other in a P2P way)
  • Enable / Be sure circuit-v2 relays are enabled (webrtc in browsers first require a two way datachannel to exchange SDP (Session Description Protocol)), this will use websocket or webtransport nodes in the network to setup that.
  • In your QR code pack the CID and all of the maddrs helia thinks it is listening on (that means webrtc and relays)
  • Then when scanning the QR first try to connect to the node giving all the addresses you discovered. This should do a webtransport or websocket connection to a Kubo or other native node, then do the relay handshake to encrypt the relayed connection between the two browser nodes, then finally on this they should be able to do SDP exchange and handle ICE.
  • Download the CID over the webrtc connection that has been openned.

@Jorropo thank you very much for your response. I don’t feel enough power to do first 2 steps. Could you recommend me any similar project which has done it?

I’ve been having trouble setting helia up on next.js with webpack. The node comes up but is not reachable from my local ipfs daemon (Also not part of the DHT when testing with https://pl-diagnose.on.fleek.co/) Content is added on the browser node and a cid is generated, but reloading the app creates a new node which cannot retrieve the content from the cid generated by the previous node.

@SgtPooki I need your help figuring this out.

If you are using default Helia settings (with memory based datastore, which is the default) then your PeerId will be re-generated on every reload. You need to use a persistent datastore to persist the PeerId of a Node.

This is part of js-libp2p, see https://github.com/libp2p/js-libp2p/blob/a2fb80a1d533701f77d1b3649a3a4cb8680bac41/packages/libp2p/src/libp2p.ts#L430-L433

1 Like

there’s gotta be a mechanism for waiting until a message is recieved via the QRC