Skip to content

Instantly share code, notes, and snippets.

@yornaath
Created September 20, 2022 11:36
Show Gist options
  • Save yornaath/20f1cdc36ee8fc2bf3c6470ebc2192f2 to your computer and use it in GitHub Desktop.
Save yornaath/20f1cdc36ee8fc2bf3c6470ebc2192f2 to your computer and use it in GitHub Desktop.
Zeitgeist get market metadata
import * as ipfsClient from "ipfs-http-client";
import CID from "cids";
import { u8aToString } from "@polkadot/util";
const main = async (
metadata: string = "0x153065f773b9d3b19b9ec3ef4641bc62e714b77c086d1fa1b263331aa994789d7a8f7e21f0ceaf11ee285a2490821ca348b0"
) => {
const ipfs = await ipfsClient.create({
url: "http://ipfs.zeitgeist.pm:5001/",
});
const cid = new CID(`f0155` + metadata.slice(2));
let buf: Uint8Array[] = [];
for await (const chunk of ipfs.cat(cid as any) as any) {
buf.push(chunk);
}
const out = buf.map(u8aToString).reduce((acc, n) => acc + n);
console.log(JSON.parse(out));
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment