How to link arweave metadata to ERC721 contract?

Hi,

I successfully worked with IPFS Folders to host and access my metadata with an ERC-721 contract.
My json files are stored in an IPFS folder and the files named 1,2,3,4....

If I query tokenURI(1) i get
ipfs://path_to_ipfs_folder/1

If I query tokenURI(2) i get
ipfs://path_to_ipfs_folder/2

So far so good. File "1" is a json holding information and linking to the image url.
Everything works as expected - no problems so far. Linking to image and metadata works fine.

No I wanted to try Arweave for persisting metadata.
I upload the images in a folder named "images" and get for an example image the following id:
FEFJ8qmM49TFeWZOLbCHX9jcjkdxttBw8-gGSXJpIqU
This can be viewed with:
https://arweave.net/FEFJ8qmM49TFeWZOLbCHX9jcjkdxttBw8-gGSXJpIqU

Second step is creating the metadata.json file with the corresponding image arweave uris.

Metadata is designed like "ERC721 Metadata JSON Schema" defines and holds the information regarding the image.

{
[...]
"image": "https://arweave.net/FEFJ8qmM49TFeWZOLbCHX9jcjkdxttBw8-gGSXJpIqU",
[...]
}

I call this file "1" and save it on arweave within the folder metadata.
The folder lives here:
https://arweave.net/xlWqxJLHdS_PZtWbsPPY-K5yHv5dIMLji-SIdYrRzg0/

If I set the uri within the contract at the folder ID:
ar://xlWqxJLHdS_PZtWbsPPY-K5yHv5dIMLji-SIdYrRzg0
or
https://arweave.net/xlWqxJLHdS_PZtWbsPPY-K5yHv5dIMLji-SIdYrRzg0/
and try to get the Token URI I won´t get informations regarding the item.
https://arweave.net/xlWqxJLHdS_PZtWbsPPY-K5yHv5dIMLji-SIdYrRzg0/**1**
--> this won´t work because the file has an onw unique id in arweave and can´t be found with "/1".

The json itself has a different address:
https://arweave.net/HnnA6It8FprXkG_qDKQ3oIohBSv0AkNHpnAf5GRGWxU/

So I conclude I´d had to map every address to the corresponding path. I understand, that this is a no go...

Another option would be to put all metadata json elements in one file save it to arweave and query only the part needed with an API like
"https:/myrestapi/1" --> loads the json json from arweave and parses the element given in the uri ("/1".

Example:
[ element: 1 {
{ name: "1",
....
"image": "https://arweave.net/FEFJ8qmM49TFeWZOLbCHX9jcjkdxttBw8-gGSXJpIqU",
....
}},
element: 2 {
{name: "2",
....
"image": "https://arweave.net/....",
...

API submitted with /1 gives:

{ name: "1",
....
"image": "https://arweave.net/FEFJ8qmM49TFeWZOLbCHX9jcjkdxttBw8-gGSXJpIqU",
....
}

How do I link metadata json files held in arweave the right way?
Hopefully I missing something. Seems like a bad workaround because the interface can be shut down and the NFTs won´t find their metadata.

Thank you for your help!

I'm not familiar with Arweave so I can't answer about that. For IPFS there exists the possibility to upload a directory rather than a file, so when you request .../1 you get the file called "1" inside the directory, and this can be used for NFT ids. See:

If there is nothing like this for Arweave then this pattern is not possible and you would have to use ERC721URIStorage to set a different tokenUri for each id.

Hi frangio,
thank you for your help. I worked with IPFS in the past and ipfs://<ipfs_hash_of_the_folder>/1 worked fine. I assumed that I can do the same in arweave - upload a folder here and fill it with the files 1,2,3,..
But I think this is not as easy as expected. ERC721URIStorage needs a token already minted for setting the URI. In my imagination this could be very expensive to set for every token on ethereum.
I opened a ticket at arweave as well... If I get an answer I will update here, too.

Hi all found a solution.

For all others struggling:

You can just upload a folder with:

install it and run:

arkb deploy /path/to/your/folder/

It will upload and give you a hash - you can access all items in given folder with hash/filename.

Additional information here:

1 Like