index.js 511 B

123456789101112131415161718
  1. 'use strict';
  2. // https://github.com/ipfs/js-ipfs/tree/ipfs%400.55.4/docs/core-api
  3. const IPFS = require('ipfs');
  4. async function initialize() {
  5. const node = await IPFS.create();
  6. const node_info = await node.id();
  7. console.log('ipfs node id: ' + node_info.id);
  8. const pin = await node.add(
  9. 'webpacked ' + node_info.agentVersion
  10. + ' ' + node_info.id
  11. + ' at ' + (new Date()).toISOString()
  12. );
  13. console.log("https://ipfs.io/ipfs/" + pin.cid.toString());
  14. }
  15. initialize();