Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save datafatmunger/f65261e405a25557f14e824a0c8631fb to your computer and use it in GitHub Desktop.

Select an option

Save datafatmunger/f65261e405a25557f14e824a0c8631fb to your computer and use it in GitHub Desktop.
const IPFS = require('ipfs')
const OrbitDB = require('orbit-db')
const ipfs = new IPFS({
config: {
Addresses: {
Swarm: [
'/dns4/wrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star'
]
}
}
})
ipfs.on('error', (e) => console.error(e))
ipfs.on('ready', async () => {
var ipfsId = await ipfs.id();
const orbitdb = new OrbitDB(ipfs)
const docstore = await orbitdb.docstore(ipfsId.publicKey)
var addr = docstore.address.toString();
console.log("ADDR: " + addr);
docstore.put({ _id: 'hello world', doc: 'all the things' })
.then(() => docstore.put({ _id: 'sup world', doc: 'other things' }))
.then(() => docstore.get('world'))
.then((value) => console.log(value))
.catch((err) => console.log(err))
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment