Skip to content

Commit

Permalink
refactor(wiki): implement review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ginowine committed Jul 9, 2024
1 parent effde94 commit 06d39f8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,14 @@ import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.m
# 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.

Here's an example of how to implement this:

```solidity
function fetchNFTData(uint256 tokenId) public view returns (ISCNFT memory nftData) {
nftData = ISC.sandbox.getNFTData(ISCTypes.asNFTID(tokenId));
return nftData;
}
```

## Full Example Code
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:

Combining the above step, here’s a complete example:
## Example Code

```solidity
// SPDX-License-Identifier: MIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,14 @@ import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.m
# 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.

Here's an example of how to implement this:

```solidity
function fetchNFTData(uint256 tokenId) public view returns (ISCNFT memory nftData) {
nftData = ISC.sandbox.getNFTData(ISCTypes.asNFTID(tokenId));
return nftData;
}
```

## Full Example Code
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:

Combining the above step, here’s a complete example:
## Example Code

```solidity
// SPDX-License-Identifier: MIT
Expand Down

0 comments on commit 06d39f8

Please sign in to comment.