From 5df1669c1bb741ce62bf827943ea52ae0daa99d5 Mon Sep 17 00:00:00 2001 From: Dr-Electron Date: Tue, 27 Feb 2024 14:34:17 +0100 Subject: [PATCH] Add usage example --- .../docs/how-tos/nft/introduction.md | 3 +- .../docs/how-tos/nft/use-as-erc721.md | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/use-as-erc721.md diff --git a/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/introduction.md b/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/introduction.md index 40c830d69ab..5f400bb98d8 100644 --- a/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/introduction.md +++ b/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/introduction.md @@ -12,7 +12,6 @@ import DocCardList from '@theme/DocCardList'; # Native NFT and ERC721 The IOTA L1 has functionality to create NFTs, also called native NFTs. To use these NFTs on L2, you have -a ERC20 contract called `ERC721NFTs`. The following guides will show you how to [mint your own L1 NFT from L2](mint-nft.md), and [register](register-nft.md) it in the `ERC721NFTs` contract, -so it can be used like any other ERC721 NFT with some additional features. +a ERC20 contract called `ERC721NFTs` which contains all L1 NFTs owned by the chain. The following guides will show you how to [mint your own L1 NFT from L2](mint-nft.md), and [use](./use-as-erc721.md) it with the `ERC721NFTs` contract. \ No newline at end of file diff --git a/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/use-as-erc721.md b/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/use-as-erc721.md new file mode 100644 index 00000000000..1b32315c290 --- /dev/null +++ b/docs/build/isc/v1.0.0-rc.6/docs/how-tos/nft/use-as-erc721.md @@ -0,0 +1,33 @@ +--- +description: How to use a native NFT like an ERC721 NFT +image: /img/logo/WASP_logo_dark.png +tags: + - NFT + - EVM + - how-to +--- + +# Use as ERC721 +## About the `ERC721NFTs` contract + +The `ERC721NFTs` contract is a harcoded contract at address `0x1074030000000000000000000000000000000000`. Every L1 NFT owned by the chain can be accessed through it. In this example we will show you how to use it by taking `transferFrom` as an example. + +## Example Code + +1. ERC721 uses `tokenID` for almost all interactions with it. So we first convert our `NFTID` to a `tokenID`: + +```solidity +uint256 tokenID = uint256(NFTID.unwrap(nftID)); +``` + +:::info Token ID to NFT ID + +To go the other way around and convert a Token ID to an NFT ID, you can use the ISCTypes.asNFTID() function, by either using (`using ISCTypes for uint256;`) it on token ID like `tokenID.asNFTID();` or passing it to function like `ISCTypes.asNFTID(tokenID)`. + +::: + +2. Transfer the token with ID `tokenID`, by using the `ERC20NFTs` contract, which is exposed in the library as `ISC.nfts`, and calling the standard `transferFrom` function + +```solidity +ISC.nfts.transferFrom(msg.sender, _destination, tokenID); +```