Skip to content
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

Update Irys docs to use the latest version of Irys's tooling #738

Merged
merged 11 commits into from
Oct 7, 2024
40 changes: 19 additions & 21 deletions docs/developers/guides/community/irys/irys-dynamic-nfts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ description: Create NFTs that evolve based on user actions.
---

Data on Irys is permanent and immutable, but you can use
[Irys' mutable references](https://arweave-tools.irys.xyz/irys-sdk/mutable-references) to simulate
[Irys's mutability features](https://docs.irys.xyz/build/d/features/mutability) to simulate
mutability and create dynamic NFTs that evolve based on onchain or offchain actions.

With mutable references, you create a single, static URL that is linked to a series of transactions.
A mutable-style URL is a single, static URL that is linked to a series of transactions.
You can add a new transaction to the series at any time, and the URL will always resolve to the
most recent transaction.

<img src="/img/docs/build-on-linea/tooling/permanent-data/irys/mutable-references.png" />

In this guide, you will create a dynamic NFT using Irys' mutable references. Dynamic NFTs are NFTs whose
In this guide, you will create a dynamic NFT using Irys's mutability features. Dynamic NFTs are NFTs whose
metadata evolves over time. They are commonly used in:

- Gaming projects where in-game assets evolve as players progress.
Expand All @@ -32,23 +32,21 @@ metadata, simulating the automatic changes that would occur through player inter
[Install the Irys CLI](../../../tooling/permanent-data/irys/irys-quickstart.mdx#irys-cli) to upload
your images and metadata.

## Create mutable references

Mutable references are a way to simulate "mutability".
## How to create a "mutable" URL

1. Create a single static URL that is tied to a chain of transactions:

```js
const irys = await getIrys();
const receiptOne = await irys.upload("First TX");
const irysUploader = await getIrysUploader();
const receiptOne = await irysUploader.upload("First TX");
console.log(`TX 1 uploaded https://gateway.irys.xyz/mutable/${receiptOne.id}`);
```

1. Update the "chain" by posting a second transaction (from the same wallet) tagged with the original transaction's ID:

```js
const tags = [{ name: "Root-TX", value: receiptOne.id }];
const receiptTwo = await irys.upload("Second TX", { tags });
const receiptTwo = await irysUploader.upload("Second TX", { tags });
console.log(`TX 2 uploaded https://gateway.irys.xyz/mutable/${receiptOne.id}`);
```

Expand Down Expand Up @@ -133,7 +131,7 @@ contract SuperMon is ERC721URIStorage {
/>
</div>

1. Fund the Irys Devnet node with 0.1 [Linea Sepolia ETH](https://www.infura.io/faucet/linea) to pay
1. Fund the Irys Devnet with 0.1 [Linea Sepolia ETH](https://www.infura.io/faucet/linea) to pay
for your uploads.

:::info
Expand Down Expand Up @@ -183,7 +181,7 @@ contract SuperMon is ERC721URIStorage {
{
"name": "SuperMon",
"symbol": "SMON",
"image": "https://gateway.irys.xyz/QH3rksVhbFg5L9vvjGzb4POUibCEG-TGPInmofp-O-o",
"image": "https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x",
"description": "Super dooper, changing shapes, changing power",
"attributes": [
{
Expand All @@ -194,11 +192,11 @@ contract SuperMon is ERC721URIStorage {
}
```

```jason filename="metadata-level-2.json"
```json filename="metadata-level-2.json"
{
"name": "SuperMon",
"symbol": "SMON",
"image": "https://gateway.irys.xyz/QH3rksVhbFg5L9vvjGzb4POUibCEG-TGPInmofp-O-o",
"image": "https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x",
"description": "Super dooper, changing shapes, changing power",
"attributes": [
{
Expand All @@ -210,11 +208,11 @@ contract SuperMon is ERC721URIStorage {
}
```

```jason filename="metadata-level-3.json"
```json filename="metadata-level-3.json"
{
"name": "SuperMon",
"symbol": "SMON",
"image": "https://gateway.irys.xyz/QH3rksVhbFg5L9vvjGzb4POUibCEG-TGPInmofp-O-o",
"image": "https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x",
"description": "Super dooper, changing shapes, changing power",
"attributes": [
{
Expand All @@ -236,19 +234,19 @@ contract SuperMon is ERC721URIStorage {
--provider-url https://rpc.sepolia.linea.build
```

The CLI will return a URL similar to `https://gateway.irys.xyz/NDtKvjlmZL2iXUPmX6P-BuvtnvAEFkUiQWG8ToyK5FM`.
The CLI will return a URL similar to `https://gateway.irys.xyz/2N9YPwW3KdWcDsCZr4EWzZryZVUxbDN4oKRiutLxKJrF`.
To convert that to a mutable references URL, interpolate it by adding `/mutable/` after the
domain and before the transaction ID.

Your final URL will be similar to `https://gateway.irys.xyz/mutable/NDtKvjlmZL2iXUPmX6P-BuvtnvAEFkUiQWG8ToyK5FM`.
Your final URL will be similar to `https://gateway.irys.xyz/mutable/2N9YPwW3KdWcDsCZr4EWzZryZVUxbDN4oKRiutLxKJrF`.

## Mint the NFT

To mint your NFT in [Remix](https://remix.ethereum.org/):

1. Under **Deployed Contracts**, locate your contract and expand it to see its functions.
1. Under the `Mint` function, enter the wallet address you want to mint the NFT to and the
metadata URL (e.g. `https://gateway.irys.xyz/mutable/NDtKvjlmZL2iXUPmX6P-BuvtnvAEFkUiQWG8ToyK5FM`) from
metadata URL (e.g. `https://gateway.irys.xyz/mutable/2N9YPwW3KdWcDsCZr4EWzZryZVUxbDN4oKRiutLxKJrF`) from
the previous step.
1. Select **Transact**.

Expand All @@ -263,15 +261,15 @@ You can now view the NFT on the [Opensea Testnet](https://testnets.opensea.io/ac

To "mutate" the NFT, upload a new version of the metadata tagging it as having a `Root-TX`
equal to the transaction ID of your first transaction. In this example, we pass the
value of `NDtKvjlmZL2iXUPmX6P-BuvtnvAEFkUiQWG8ToyK5FM`, however make sure to change this to match your
value of `2N9YPwW3KdWcDsCZr4EWzZryZVUxbDN4oKRiutLxKJrF`, however make sure to change this to match your
unique transaction ID.

```bash
irys upload metadata-level-2.json \
-n devnet \
-t linea-eth \
-w 6dd5e....54a120201cb6a \
--tags Root-TX NDtKvjlmZL2iXUPmX6P-BuvtnvAEFkUiQWG8ToyK5FM \
--tags Root-TX 2N9YPwW3KdWcDsCZr4EWzZryZVUxbDN4oKRiutLxKJrF \
--provider-url https://rpc.sepolia.linea.build
```

Expand All @@ -287,7 +285,7 @@ Give it a few minutes and your updated NFT should be visible.
## Free metadata uploads

This tutorial uses the Irys Devnet where uploads are kept for ~60 days and are paid for with free
faucet currencies. When deploying production projects, you'll use Irys' mainnet where uploads are permanent.
faucet currencies. When deploying production projects, you'll use Irys's mainnet where uploads are permanent.

Uploads of less than 100 KiB are free on Irys, which is more than enough for most metadata files. This
means projects can let users "evolve" their NFTs without having to pay gas fees.
Expand Down
38 changes: 19 additions & 19 deletions docs/developers/guides/community/irys/irys-nfts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ image: /img/socialCards/create-an-nft.jpg
description: Build permanent NFTs using Irys and Linea.
---

You can use [Irys](../../../tooling/permanent-data/irys/overview.mdx) to create an NFT on Linea. To do this:
You can use [Irys](../../../tooling/permanent-data/irys/overview.mdx) to create an NFT on Linea in three steps:

1. Deploy your smart contract on Linea
2. Permanently store your NFT assets on Irys
3. Mint your NFTs using metadata stored on Irys

When you upload NFTs to Irys, you make a one-time payment for permanent access. Creators and
When you upload NFTs to Irys, you make a one-time payment for and your data is guaranteed to be retrievable forever. Creators and
collectors benefit from the assurance that their NFTs are preserved indefinitely. NFT metadata and
images stored are Irys are permanent and immutable.

Expand Down Expand Up @@ -86,8 +86,12 @@ upload your assets to Irys. You can also do the same using the
Install the CLI globally using the `-g` flag. Depending on your setup, you may or may not need to use `sudo`.

```bash
npm i -g @irys/sdk
sudo npm i -g @irys/sdk
npm i -g @irys/cli
```
Depending on your setup, you may need to use the sudo command.

```bash
sudo npm i -g @irys/cli
```

#### Upload single assets
Expand All @@ -96,7 +100,6 @@ To upload a single file, use the command `irys upload`.

```bash
irys upload myNFT.png \
-n mainnet \
-t linea-eth \
-w bf20......c9885307
```
Expand All @@ -106,7 +109,7 @@ The CLI will output the link to download the file from the Irys gateway.
Example:

```bash
Uploaded to https://gateway.irys.xyz/LRtYnBeecdJinCnvdf4obH9ikUGhftO8e1ZDxKtNtHY
Uploaded to https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x
```

#### Upload multiple assets
Expand All @@ -115,38 +118,37 @@ To upload a folder of files, use the command `irys upload-dir`.

```bash
irys upload-dir myNFTs \
-n mainnet \
-t linea-eth \
-w bf20......c9885307
```

The CLI outputs a link to the manifest for the upload:

```bash
https://gateway.irys.xyz/pA__LOI0BjYl5jSKAPshdbz4XZTO7c5ckhtKtiknAL4
https://gateway.irys.xyz/A7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiG8CM6Yv1f
```

The CLI also produces a `.json` file containing the transaction IDs of each upload:

```json
{
"manifest": "arweave/paths",
"manifest": "irys/paths",
"version": "0.1.0",
"paths": {
"nft1.png": { "id": "gi9aMxCy2H3zWtxk2Ro9UIAUZItSFrOjEq1YahEx3_g" },
"nft2.png": { "id": "-mxFojZDPEOYvL6aavxlx4LBXb57v0KBVlBbaGt5sDA" },
"nft3.png": { "id": "ro8UsTSa75mtDvXrkCVIjKFYWLfgpzer0kwpDd0yJ4c" },
"nft4.png": { "id": "z7QsiuU-amzbwDYJ0zISxrYBt-s2G-mx-FS9KpCpRho" },
"nft5.png": { "id": "642QCUF0UCo77JwgJ5Wg4LPh_JGxaug5lxAccSzQhnI" }
"nft1.png": { "id": "B7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft2.png": { "id": "C7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft3.png": { "id": "D7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft4.png": { "id": "E7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" },
"nft5.png": { "id": "F7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x" }
}
}
```

You can download files by using the transaction ID directly, or by creating a URL using the manifest
ID combined with the original file name. For example, `nft1.png` can be downloaded with either of these URLs:

- `https://gateway.irys.xyz/gi9aMxCy2H3zWtxk2Ro9UIAUZItSFrOjEq1YahEx3_g`
- `https://gateway.irys.xyz/pA__LOI0BjYl5jSKAPshdbz4XZTO7c5ckhtKtiknAL4/nft1.png`
- `https://gateway.irys.xyz/gF7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x`
- `https://gateway.irys.xyz/F7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x/nft1.png`

### Store your metadata

Expand All @@ -158,8 +160,7 @@ Create unique metadata files, one for each NFT.
{
"name": "Irys & Linea Forever",
"description": "Irys & Linea NFTs #42",
"image": "https://gateway.irys.xyz/737m0bA1kW4BlIJOg_kOGUpHAAI-3Ec9bdo8S_xTFKI",
"animation_url": "https://gateway.irys.xyz/peRdpP3pjyFQ6m4Hca5fZY5zgz7RSlE86j-_5BEwnW0",
"image": "https://gateway.irys.xyz/F7CXNp4WqwkY73TRxKR2o3gfSCw3ghhZZXiP8CM6Yv1x",
"background_color": "FEF4EE"
}
```
Expand All @@ -170,7 +171,6 @@ Upload the metadata to Irys

```console
irys upload metadata.json \
-n mainnet \
-t linea-eth \
-w bf20......c9885307
```
Expand Down
64 changes: 0 additions & 64 deletions docs/developers/tooling/permanent-data/irys/irys-query-package.mdx

This file was deleted.

Loading