References

Exploring the client API

htmlinlineipfs_script_tag
jssetupinit> txt !collapse
return (async fn=>{
  const node = await Ipfs.create({
    repo: 'ok' + Math.random(), // random so we get a new peerid every time, useful for testing
    config: {
        Addresses: {
            Swarm: [
                '/dns4/star.thedisco.zone/tcp/9090/wss/p2p-webrtc-star',
                '/dns6/star.thedisco.zone/tcp/9090/wss/p2p-webrtc-star'
            ]
        },
    }
})
  window.IpfsNode = node
  return await node
})()

js> txt #pubkey
return IpfsNode.id().then(res=>res.publicKey)
txtpubkeyUpdated 68.9w ago
CAESIOkOL4/uzuzVv7N61ijE6LLoYk27mkEGI+flpllwflLQ
js
return IpfsNode.isOnline()
txtUpdated 68.9w ago
true
js> txt !collapse #peers
return IpfsNode.swarm.peers()
js
return IpfsNode.add("dotlit!").then(res=>res.path)
txtUpdated 68.9w ago
QmeYcD38KNnj7u1qHF1fGtiZusSdLbqyMuc21hweWTwRms
js
return (async fn => {
  const hash = 
  //"QmWXdjNC362aPDtwHPUE9o2VMqPeNeCQuTBTv1NsKtwypg/myfile.txt"
  "QmeYcD38KNnj7u1qHF1fGtiZusSdLbqyMuc21hweWTwRms"
  let str = ""
  const enc = new TextDecoder("utf-8");
  for await (const chunk of IpfsNode.cat(hash)) {
    str += enc.decode(chunk)
  }
  console.log("done")
  return str

})()
txtUpdated 68.9w ago
done
dotlit!

Pub Sub