Home

Awesome

ipfs-coord logo

ipfs-coord

This is a JavaScript npm library built on top of js-ipfs. It provides the following high-level features:

This library will help IPFS peers discover one another, coordinate around a common interest, and then stay connected around that interest. It's main sub-components are:

This library will automatically track peers, connects to them through circuit-relays, and end-to-end encrypts all communication with each node. For more details, read the ipfs-coord specification.

Here are some use cases where IPFS node coordination is needed:

The ultimate goal for this library is to be a building block for building a replacement to the conventional REST API. APIs like REST or gRPC are incredibly valuable, but suffer from the same censorship risks as the rest of the web (location-based addressing). An IPFS-based API, in a fully distributed network like IPFS, must have sophisticated coordination in order for it to function properly. ipfs-coord is that coordination library.

Here is some videos and blog posts that preceded this work:

Additional content that preceded this work:

A live demo of using this library to build an e2e encrypted chat app can be interacted with here:

Install

Install the npm library: npm install --save ipfs-coord

This library requires a peer dependency of:

Example in a node.js app:

Here is an example of adding ipfs-coord to your own node.js app:

const IPFS = require('ipfs')
const BCHJS = require('@psf/bch-js')
const IpfsCoord = require('ipfs-coord')

async function start() {
  // Create an instance of bch-js and IPFS.
  const bchjs = new BCHJS()
  const ipfs = await IPFS.create()

  // Pass bch-js and IPFS to ipfs-coord when instantiating it.
  const ipfsCoord = new IpfsCoord({
    ipfs,
    bchjs,
    type: 'node.js'
  })

  await ipfsCoord.start()
  console.log('IPFS and the coordination library is ready.')
}
start()

Example in a browser app:

This example is exactly the same, except when instantiating the ipfs-coord library, you want to specify the type as browser.

import IPFS from 'ipfs'
import BCHJS from '@psf/bch-js'
import IpfsCoord from 'ipfs-coord'

async function start() {
  // Create an instance of bch-js and IPFS.
  const bchjs = new BCHJS()
  const ipfs = await IPFS.create()

  // Pass bch-js and IPFS to ipfs-coord when instantiating it.
  const ipfsCoord = new IpfsCoord({
    ipfs,
    bchjs,
    type: 'browser'
  })

  await ipfsCoord.start()
  console.log('IPFS and the coordination library is ready.')
}
start()

Development Environment

Setup a development environment:

git clone https://github.com/christroutner/ipfs-coord
cd ipfs-coord
npm install
npm test

Licence

MIT