Skip to content

Instantly share code, notes, and snippets.

@fredyteheranto
Forked from VictorTaelin/upload_json_to_ipfs.js
Created September 22, 2021 03:27
Show Gist options
  • Select an option

  • Save fredyteheranto/dbb5bfdc9ce3d85fd5ca854ef242a18e to your computer and use it in GitHub Desktop.

Select an option

Save fredyteheranto/dbb5bfdc9ce3d85fd5ca854ef242a18e to your computer and use it in GitHub Desktop.
Upload a JSON to IPFS
const ipfs = require("nano-ipfs-store").at("https://ipfs.infura.io:5001");
(async () => {
const doc = JSON.stringify({
foo: "bar",
tic: "tac"
});
const cid = await ipfs.add(doc);
console.log("IPFS cid:", cid);
console.log(await ipfs.cat(cid));
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment