-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(wasp): create a guide for getting an on-chain NFT data (#1648)
* feat(wiki): create a guide for getting an on-chain NFT data * refactor(wiki): implement review suggestions
- Loading branch information
Showing
4 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-nft-data.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
description: How to get information about an on-chain NFT. | ||
image: /img/logo/WASP_logo_dark.png | ||
tags: | ||
- EVM | ||
- how-to | ||
- native tokens | ||
- L2 NFTs | ||
--- | ||
import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md'; | ||
|
||
# Get On-Chain NFT Data | ||
|
||
This guide explains how to use the [`getNFTData`](../../../reference/magic-contract/ISCSandbox.md#getnftdata) function within a smart contract to fetch information about a specific on-chain NFT on the IOTA network. | ||
|
||
<GetNftMetadata /> | ||
|
||
## How to Use the `getNFTData` Function | ||
|
||
The `getNFTData` function retrieves data for an NFT based on its identifier. It returns a struct of type [`ISCNFT`](../../../reference/magic-contract/ISCTypes.md#iscnft), which contains various properties of the NFT like the issuer, metadata, owner, and NFTID. To use this function, you need to create a function in your smart contract that calls `getNFTData` and processes its return value, as shown in the example contract below: | ||
|
||
## Example Code | ||
|
||
```solidity | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import "@iota/iscmagic/ISC.sol"; | ||
import "@iota/iscmagic/ISCTypes.sol"; | ||
contract NFTMetadata { | ||
function fetchNFTData(uint256 tokenId) public view returns (ISCNFT memory nftData) { | ||
nftData = ISC.sandbox.getNFTData(ISCTypes.asNFTID(tokenId)); | ||
return nftData; | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-nft-data.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
--- | ||
description: How to get information about an on-chain NFT. | ||
image: /img/logo/WASP_logo_dark.png | ||
tags: | ||
- EVM | ||
- how-to | ||
- native tokens | ||
- L2 NFTs | ||
--- | ||
import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md'; | ||
|
||
# Get On-Chain NFT Data | ||
|
||
This guide explains how to use the [`getNFTData`](../../../reference/magic-contract/ISCSandbox.md#getnftdata) function within a smart contract to fetch information about a specific on-chain NFT on the IOTA network. | ||
|
||
<GetNftMetadata /> | ||
|
||
## How to Use the `getNFTData` Function | ||
|
||
The `getNFTData` function retrieves data for an NFT based on its identifier. It returns a struct of type [`ISCNFT`](../../../reference/magic-contract/ISCTypes.md#iscnft), which contains various properties of the NFT like the issuer, metadata, owner, and NFTID. To use this function, you need to create a function in your smart contract that calls `getNFTData` and processes its return value, as shown in the example contract below: | ||
|
||
## Example Code | ||
|
||
```solidity | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.0; | ||
import "@iota/iscmagic/ISC.sol"; | ||
import "@iota/iscmagic/ISCTypes.sol"; | ||
contract NFTMetadata { | ||
function fetchNFTData(uint256 tokenId) public view returns (ISCNFT memory nftData) { | ||
nftData = ISC.sandbox.getNFTData(ISCTypes.asNFTID(tokenId)); | ||
return nftData; | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters