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

Add a get IRC27NFT Metadata guide #1583

Merged
merged 14 commits into from
Jun 18, 2024
5 changes: 5 additions & 0 deletions docs/build/isc/v1.1/docs/_admonitions/_ERC721.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::info ERC721

As your L1 NFT is always registered as [ERC721](https://eips.ethereum.org/EIPS/eip-721), you might want to get the metadata like `tokenURI` from there. Using `getIRC27NFTData` is normally only needed if you need special [IRC27](https://wiki.iota.org/tips/tips/TIP-0027/) metadata.

:::
5 changes: 5 additions & 0 deletions docs/build/isc/v1.1/docs/_admonitions/_IRC27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::info IRC27NFTMetadata URI

The uri property contains a JSON object which follows the `ERC721` standard. This JSON is also returned by the [`tokenURI`](../../../reference/magic-contract/ERC721NFTs.md#tokenuri) function from the `ERC721NFTs` contract.
Ginowine marked this conversation as resolved.
Show resolved Hide resolved

:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::tip Mint an NFT

Mint your first NFT following our how to [mint an NFT guide](../../../how-tos/core-contracts/nft/mint-nft.md#about-nfts).

:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
description: How to get NFT metadata from a L1 NFT
image: /img/logo/WASP_logo_dark.png
tags:
- NFT
- EVM
- how-to
---
import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md';
import ERC721Admonition from '../../../_admonitions/_ERC721.md';
import IRC27Admonition from '../../../_admonitions/_IRC27.md';

# Get IRC27 NFT Metadata

<ERC721Admonition />

This guide explains how to use the [`getIRC27NFTData`](../../../reference/magic-contract/ISCSandbox.md#getirc27nftdata) function within a smart contract to fetch information about a specific IRC27 NFT on the IOTA Network.

<GetNftMetadata />

## Understanding the `getIRC27NFTData` Function

The [`getIRC27NFTData`](../../../reference/magic-contract/ISCSandbox.md#getirc27nftdata) function retrieves metadata for an IRC27 NFT based on its identifier. IRC27 is a series of standards to support interoperable and universal NFT systems throughout the IOTA ecosystem.

## How To Use `getIRC27NFTData`

Create a function called `fetchIRC27NFTData` in your contract that calls `getIRC27NFTData` and processes its return value. `getIRC27NFTData` returns a struct of type [`IRC27NFTMetadata`](../../../reference/magic-contract/ISCTypes.md#irc27nftmetadata) which contains properties like the NFT name, uri and more.

<IRC27Admonition/>

```solidity
function fetchIRC27NFTData(uint256 tokenId) public view returns (IRC27NFT memory irc27NftData) {
irc27NftData = ISC.sandbox.getIRC27NFTData(tokenId.asNFTID());
return irc27NftData;
}
```

## Full Example Contract

Combining all the above steps, here’s a complete example:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@iota/iscmagic/ISC.sol";
import "@iota/iscmagic/ISCTypes.sol";

contract IRCNFTMetadata {

function fetchIRC27NFTData(uint256 tokenId) public view returns (IRC27NFT memory irc27NftData) {
irc27NftData = ISC.sandbox.getIRC27NFTData(tokenId.asNFTID());
Ginowine marked this conversation as resolved.
Show resolved Hide resolved
return irc27NftData;
}
}
```
5 changes: 5 additions & 0 deletions docs/build/isc/v1.1/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,11 @@ module.exports = {
label: 'Use as ERC721',
id: 'how-tos/core-contracts/nft/use-as-erc721',
},
{
type: 'doc',
label: 'Get NFT Metadata',
id: 'how-tos/core-contracts/nft/get-nft-metadata',
},
],
},
{
Expand Down
5 changes: 5 additions & 0 deletions docs/build/isc/v1.3-alpha/docs/_admonitions/_ERC721.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::info ERC721

As your L1 NFT is always registered as [ERC721](https://eips.ethereum.org/EIPS/eip-721), you might want to get the metadata like `tokenURI` from there. Using `getIRC27NFTData` is normally only needed if you need special [IRC27](https://wiki.iota.org/tips/tips/TIP-0027/) metadata.

:::
5 changes: 5 additions & 0 deletions docs/build/isc/v1.3-alpha/docs/_admonitions/_IRC27.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::info IRC27NFTMetadata URI

The uri property contains a JSON object which follows the `ERC721` standard. This JSON is also returned by the [`tokenURI`](../../../reference/magic-contract/ERC721NFTs.md#tokenuri) function from the `ERC721NFTs` contract.
Ginowine marked this conversation as resolved.
Show resolved Hide resolved

:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:::tip Mint an NFT

Mint your first NFT following our how to [mint an NFT guide](../../../how-tos/core-contracts/nft/mint-nft.md#about-nfts).

:::
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
description: How to get NFT metadata from a L1 NFT
image: /img/logo/WASP_logo_dark.png
tags:
- NFT
- EVM
- how-to
---
import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md';
import ERC721Admonition from '../../../_admonitions/_ERC721.md';
import IRC27Admonition from '../../../_admonitions/_IRC27.md';

# Get IRC27 NFT Metadata

<ERC721Admonition />

This guide explains how to use the [`getIRC27NFTData`](../../../reference/magic-contract/ISCSandbox.md#getirc27nftdata) function within a smart contract to fetch information about a specific IRC27 NFT on the IOTA Network.

<GetNftMetadata />

## Understanding the `getIRC27NFTData` Function

The [`getIRC27NFTData`](../../../reference/magic-contract/ISCSandbox.md#getirc27nftdata) function retrieves metadata for an IRC27 NFT based on its identifier. IRC27 is a series of standards to support interoperable and universal NFT systems throughout the IOTA ecosystem.

## How To Use `getIRC27NFTData`

Create a function called `fetchIRC27NFTData` in your contract that calls `getIRC27NFTData` and processes its return value. `getIRC27NFTData` returns a struct of type [`IRC27NFTMetadata`](../../../reference/magic-contract/ISCTypes.md#irc27nftmetadata) which contains properties like the NFT name, uri and more.

<IRC27Admonition/>

```solidity
function fetchIRC27NFTData(uint256 tokenId) public view returns (IRC27NFT memory irc27NftData) {
irc27NftData = ISC.sandbox.getIRC27NFTData(tokenId.asNFTID());
return irc27NftData;
}
```

## Full Example Contract

Combining all the above steps, here’s a complete example:

```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@iota/iscmagic/ISC.sol";
import "@iota/iscmagic/ISCTypes.sol";

contract IRCNFTMetadata {

function fetchIRC27NFTData(uint256 tokenId) public view returns (IRC27NFT memory irc27NftData) {
irc27NftData = ISC.sandbox.getIRC27NFTData(tokenId.asNFTID());
return irc27NftData;
}
}
```
Loading