Created
September 20, 2022 11:36
-
-
Save yornaath/20f1cdc36ee8fc2bf3c6470ebc2192f2 to your computer and use it in GitHub Desktop.
Zeitgeist get market metadata
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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