Photo by Alexander Elliott
Abandon IPFS, embrace AR 💮
The tutorial mainly goes through how to abandon IPFS and use AR to create NFTs.
Final result display: Click here
ArDrive Preparation#
-
You can experience 0.2AR for free. Refer to ArDrive official website for the steps. Send a tweet, it's not easy to verify with a small account to receive 0.2AR. After completing this step, there will be a json file containing wallet private key information.
-
After completion, use ArConnect, the AR plugin wallet, to import the Json file we just downloaded. Pay attention to the steps demonstrated below.
-
After successfully importing the wallet, log in to https://app.ardrive.io/ to register and log in.
Provide a username and password to register.
Using ArDrive#
-
Drive and Folder. Drive contains many Folders, and Drive can be shared with others separately. Pay attention ⚠️ when creating a Drive, you will be asked to choose Public or Private. For details on Public and Private, please refer to Here. Just understand the literal meaning, no need for further explanation.
- Note that each Drive and Folder will have its own identifier,
https://app.ardrive.io/#/drives/ee70c85b-f140-49c7-80b1-856625fcb103/folders/77c4b073-5ce5-4f5a-bd59-b3a14e29a68d
for example,- FolderID=
77c4b073-5ce5-4f5a-bd59-b3a14e29a68d
will be used when uploading, specify the FolderID for uploading. - DriveID=
ee70c85b-f140-49c7-80b1-856625fcb103
- FolderID=
- Note that each Drive and Folder will have its own identifier,
-
Simply upload the data. After uploading the image, we will have a display like this. After obtaining the DataID, use this gateway plus the dataID to access it, for example, https://arweave.net/l1n24_cORIcDAOkzFc0I1IWs2qvv-eelHp4Qgb1f9vk
NFT#
-
Upload images.
-
At this point, we can upload images to AR and get the corresponding DataID.
const { readJWKFile, arDriveFactory, wrapFileOrFolder, EID } = require('ardrive-core-js'); // wallet is your json file, the one downloaded earlier // filePath is the path of the png // FolderID is the one we mentioned above async function upload(wallet, filePath, folderID){ const arDrive = arDriveFactory({ wallet: wallet }); const wrappedEntity = wrapFileOrFolder(filePath); const destFolderId = EID(folderID); const uploadFileResult = await arDrive.uploadAllEntities({ entitiesToUpload: [{ wrappedEntity, destFolderId }] }); let {created} = uploadFileResult; // The returned value is the DataID return created[0].dataTxId.transactionId; }
-
After uploading each image, the DataID is returned, and then a JsonFile is generated.
{ "name":"name #0", "description":"balabala.", "traits":[ {"trait_type":"backgroud","value":"blue"}, {"trait_type":"body","value":"body"}, {"trait_type":"eye","value":"happy"}, {"trait_type":"hat","value":"hat"}, {"trait_type":"clothes","value":"hoodie_B"}, {"trait_type":"plant","value":"alsophilaspinulosa"} ], "image":"https://arweave.net/l1n24_cORIcDAOkzFc0I1IWs2qvv-eelHp4Qgb1f9vk"}
-
Here, let's talk about the cost. Each transaction has two fields related to the cost. For example, this tx 👈
- Fee: The cost we spent on storing this file, which is the main part of storing the file 🤕. The above tx corresponds to a 655kb png, and the Fee is 0.000109AR.
In terms of Fee alone, it is generally cheaper than Pinata, of course, Infura's price is better, but Infura is too slow in terms of access.
- Value: This field is similar to the value field on eth, but gas is also included here.
- Fee: The cost we spent on storing this file, which is the main part of storing the file 🤕. The above tx corresponds to a 655kb png, and the Fee is 0.000109AR.
-
-
Upload the json files in directory format.
-
After uploading all the png files, we will have many json files in one directory.
-
What we need to do at this time is to upload these jsonFiles in a directory-accessible form.
-
Two methods
- Note that arupload is the folder of json files, and wallet.json contains wallet private key and other information [the json file downloaded at the beginning🍎 ]
- Replace it with your own.
-
Simple: Use a third-party tool. Refer to this arkb github. This seems to charge an additional 10% fee.
-
npm install -g arkb
After installing globally -
arkb deploy ./arupload/ --wallet ./wallet.json
Use this statement to upload. -
After uploading, the following will be returned.
This URL plus the suffix, for example, https://arweave.net/8qWYL9oyX5oPU9dwMHWii8ZlonEYatK-P2k_RXpfbs4/1.json can be accessed.
-
-
Complex: More native, AR's own set of things. Refer to ardrive-cli github
-
npm install -g ardrive-cli
-
ardrive upload-file --local-path ./arupload/ --parent-folder-id "2639094e-cb4a-4546-b5fb-f582db582fae" -w ./wallet.json
Note the parent-folder-id parameter here, which is the FolderID we mentioned above.
-
ardrive create-manifest -f "2639094e-cb4a-4546-b5fb-f582db582fae" -w ./wallet.json
Similarly, -f here is the folderID.
-
After uploading, the following will be returned.
-
This URL plus the suffix, for example, https://arweave.net/ruwoIvbk7oLa87xKUTd-_DY4MGJ6UR8iWEE3egRkfOI/arupload/1.json can be accessed.
-
-
-
Basically, it ends here. Set the tokenURI on etherscan, format: ar//《Path》. For example, based on the complex red box value above, it should be set as: ar://ruwoIvbk7oLa87xKUTd-_DY4MGJ6UR8iWEE3egRkfOI/arupload/
References#
https://mirror.xyz/pfeffunit.eth/iLX1IKglGDxRTufg64RdYJCrNRAMIogmLhfdJ6ZAXUY
https://blog.developerdao.com/getting-started-with-arweave#heading-introduction-to-arweave