UNPKG

know-js

Version:

JavaScript library for sending Know transactions from the client or server

26 lines (23 loc) 733 B
const IpfsApi = require('ipfs-api'); const OrbitDB = require('orbit-db'); const fs = require("fs"); const ipfs = IpfsApi({ host: '35.231.12.243', port: '5001', protocol: 'http' }); const orbitdb = new OrbitDB(ipfs) async function testOritDb() { const db = await orbitdb.keyvalue('hello', { overwrite: true }); await db.load(); // console.log(await db.put("hoank", {name: 'hoank'})); console.log(db.get("hoank")) } async function testIpfs() { let fileStream = await fs.readFileSync("test.txt"); let hash = await ipfs.files.add(fileStream); console.log(hash) let data = await ipfs.files.cat("QmfPBYQBfW7GMj15BxXMfu7ZVJWmaqipGpnp8caDWvW5ua"); console.log(data.toString()); } testIpfs()