-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I get the root hash for the bzz protocol? #13
Comments
For that you would need also to construct a manifest (with the mantaray-js library) and add the filesystem/folder metadata in it. Then serialize the manifest, get the BMT hash of the root chunk of the manifest as the reference that you can use for the I hacked together an example that can upload a single file or folder and returns a reference that can be used as the root hash for the bzz protocol here: |
@agazso I don't seem to understand that library well. const node = new MantarayNode()
node.addFork(new TextEncoder().encode("/"), hash, {
"Content-Type": "video/mp4",
Filename: Buffer.from(hash).toString("hex"),
})
const reference = Buffer.from(node.serialize()).toString("hex") I get this error: |
I haven't used const storageSaver = async (data: Uint8Array) => splitAndEnqueueChunks(data, queue, context) The reason to do this is that it may happen with multiple files or with folders that your manifest chunk grows bigger than a single chunk and then the manifest data itself is required to split into multiple chunks with the same logic as you would use for a file. If you just need the address without uploading to bee you can replace the I don't know if this is the simplest way to solve your original question but I know that this works because I tried it and managed to get the same hash as with Bee. However I found another gotcha in the mantaray library: there is a missing padding after the metadata and that can cause differences and therefore different content hash. But after fixing that bug it produced the same result as Bee. |
Thank you @agazso, I'll give it a try when they'll fix it. |
I can retrieve the root hash for the
/bytes
endpoint like this:but if I wanted to upload that file to
/bzz
how can I get the correct hash?The text was updated successfully, but these errors were encountered: