[object Object][object Object][object Object][object Object][object Object][object Object][object Object][object Object]How to use Arweave for Smart Contracts & NFT Metadata | dTech Skip to content

How to use Arweave for Smart Contracts & NFT Metadata

What to upload when?

Make sure to first upload your Art as you need to reference the art in your metadata JSON files.

The Smart Contract itself only needs to point the TokenURI to your JSON which then exposes the properties and Art for Marketplaces like Opensea to display.

Upload order therefore is: Kunst -> Metadata -> Smart Contract

How to correctly upload folders to Arweave

Normally we can simply use ArDrive to get an awesome Online Filemanager backed by the Arweave Network! It’s awesome, but doesn’t give us folder/filename out of the box.

If we upload a folder called ourData which has a file named 1.png and 2.png then we want the link ourData/1.png to access that 1.png file.

To achieve that we’ll use ARKB.

Now we can upload our folder using arkb

Terminal window
arkb deploy /path/to/folder --wallet /path/to/arweave-key.json

arkb is now preparing files for upload, which may take a while.

Preparing files

after preparation we need to double check that everything is correct and confirm/deny the upload.

Doublecheck arkb upload

We’ll confirm your upload by pressing Y and hitting Enter afterwards.

arkb will now deploy our files to the Arweave network. Since it’s all in one bundle we get the folder/filename structure we want!

arkb uploading/deploying

Now we have our NFT metadata uploaded to Arweave!

arkb deployed folder

The link shown below with arweave.net/ is where you’re files are located. If you dont want to use arweave.net as gateway and want to use the generic ar:// then replace https://arweave.net with ar://.

Everything after the .net/ is the TX ID/Hash where you’re files are stored. This is permanent and based on your file contents.

If you’re familiar with NFT metadata this Hash is your baseURI.

It will be used to concatenate the TokenURI in the Smart Contract like: ar://$BASEURI/$tokenID.json where $BASEURI and $tokenID are variables representing your Arweave ID and TokenID respectively.

The baseURI shown by arkb above is: https://arweave.net/fIlS8rS9ZwkTP_IILzqHCl4bcFGneGtZRy9gK2e75CE/

In our Flux Smackman example shown here there are 1111 coins so the following URLs for each token exist:

TokenID: 0
TokenID: 1
TokenID: 1110