How to create an IPFS compatible multihash

前端 未结 5 1862
天命终不由人
天命终不由人 2020-12-30 07:00

I\'m trying to create an IPFS compatible mutihash but it is not matching. I am asking here because I have not yet found an example that takes this from hashing to the end r

5条回答
  •  失恋的感觉
    2020-12-30 07:37

    The simplest way currently is to simply use ipfs-http-client. All above previous solutions in this thread don't work for me anymore.

    import ipfsClient from "ipfs-http-client";
    const ipfs = ipfsClient(IPFS_PROVIDER, "5001", { protocol: "https" });
    
    // onlyHash: true only generates the hash and doesn't upload the file
    const hash = (await ipfs.add(new Buffer(vuln), { onlyHash: true }))[0].hash
    

提交回复
热议问题