# Pastebin PluVQkCF const IPFS = require('ipfs') const OrbitDB = require('orbit-db') const ipfsOptions = { config: { // overload the default IPFS node config, find defaults at https://github.com/ipfs/js-ipfs/tree/master/src/core/runtime "Addresses": { "Swarm": [ "/ip4/127.0.0.1/tcp/4001", "/ip6/::/tcp/4001", "/ip4/127.0.0.1/tcp/4002/ws" ], "Announce": [], "NoAnnounce": [], "API": "/ip4/127.0.0.1/tcp/5001", "Gateway": "/ip4/127.0.0.1/tcp/8080" } }, EXPERIMENTAL: { pubsub: true } } // Create IPFS instance const ipfs = new IPFS(ipfsOptions) ipfs.on('error', (e) => console.error(e)) ipfs.on('ready', async () => { const id = await ipfs.id() console.log(id); const orbitdb = new OrbitDB(ipfs, "./testreplicate") console.log("Database created") // Create a database var testDBAddr = "/orbitdb/REMOTE_HASH/DB_ID" const replicateddb = await orbitdb.log(testDBAddr) await replicateddb.load() console.log("Database loaded") // replicateddb.events.on("replicated", (address) => { // console.log(replicateddb.iterator({ limit: -1 }).collect()) // }) // Add an entry to the database // const hash = await db.add('hello world') // Get last 5 entries // const latest = db.iterator({ limit: 5 }).collect() // console.log(JSON.stringify(latest, null, 2)) })