Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Lucas Tortora <[email protected]>
  • Loading branch information
Dr-Electron and lucas-tortora authored Mar 26, 2024
1 parent ed123c7 commit b1876d5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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` 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.
The IOTA L1 can create NFTs, also called native NFTs. To use these NFTs on L2, you have
an 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.

<DocCardList />
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ExampleCodeIntro from '../../../_partials/how-tos/token/_example_code_int
# Mint an NFT
## About NFTs

The Stardust update allows you to create your own NFT. There ias also the [IRC27](/tips/tips/TIP-0027) for NFTs. This guide will show you how to create an IRC27 L1 NFT using a L2 smart contract.
The Stardust update allows you to create your own NFTs. You can also use [IRC27](/tips/tips/TIP-0027) for NFTs. This guide will show you how to create an IRC27 L1 NFT using a L2 smart contract.

## Example Code

Expand All @@ -23,7 +23,7 @@ The Stardust update allows you to create your own NFT. There ias also the [IRC27
ISCAgentID memory agentID = ISC.sandbox.getSenderAccount();
```

3. Create a `IRC27Metadata` struct intitialised with all the needed data:
3. Create an `IRC27Metadata` struct with all the needed data:

```solidity
IRC27NFTMetadata memory metadata = IRC27NFTMetadata({
Expand All @@ -35,9 +35,9 @@ IRC27NFTMetadata memory metadata = IRC27NFTMetadata({
});
```

4. Create all the data for the core contract call. To do that, we create a new `ISCDict` with 2 parameters like specified in the reference docs for [`mintNFT`](../../../reference/core-contracts/accounts.md#mintnfti-immutabledata-a-agentid-c-collectionid-w-withdrawonmint)
`I` is the immutable metadata we fill with the IRC27 metadata and
`a` is the AgendID of the owner of the NFT
4. Create all the data for the core contract call. To do so, you should create a new `ISCDict` with 2 parameters like specified in the reference docs for [`mintNFT`](../../../reference/core-contracts/accounts.md#mintnfti-immutabledata-a-agentid-c-collectionid-w-withdrawonmint)
* `I` is the immutable metadata we fill with the IRC27 metadata and
* `a` is the AgendID of the owner of the NFT

```solidity
ISCDict memory params = ISCDict(new ISCDictItem[](2));
Expand All @@ -47,11 +47,11 @@ params.items[1] = ISCDictItem("a", agentID.data);

:::info IRC27NFTMetadataToString

The full example below contains the `IRC27NFTMetadataToString` which just converts the IRC27Metadata struct into a string.
The full example below calls the `IRC27NFTMetadataToString` function, which simply converts the IRC27Metadata struct into a string.

:::

5. Call the magic contract `call` function with all the parameters. We need to specify the core contract we want to call, which in our case is [`account`](../../../reference/core-contracts/accounts.md) and the function for [minting an NFT](../../../reference/core-contracts/accounts.md#mintnfti-immutabledata-a-agentid-c-collectionid-w-withdrawonmint)
5. Call the magic contract `call` function with all the parameters. You should specify the core contract you want to call, which in this case is the [`account`](../../../reference/core-contracts/accounts.md) contract, and the function for [minting an NFT](../../../reference/core-contracts/accounts.md#mintnfti-immutabledata-a-agentid-c-collectionid-w-withdrawonmint)

```solidity
ISCDict memory ret = ISC.sandbox.call(
Expand All @@ -62,7 +62,7 @@ ISCDict memory ret = ISC.sandbox.call(
);
```

6. The call return value will contain a mintID which we can use in for example another contract function to get the actual L1 NFT ID once it got created with the [`accounts.NFTIDbyMintID`](../../../reference/core-contracts/accounts.md#nftidbymintidd-mintid) function
6. The call return value will contain a `mintID` which we can use in, for example, another contract function to get the actual L1 NFT ID once it is created using the [`accounts.NFTIDbyMintID`](../../../reference/core-contracts/accounts.md#nftidbymintidd-mintid) function

```solidity
function getNFTIDFromMintID(bytes memory mintID) public view returns (bytes memory) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@ tags:
# 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.
The `ERC721NFTs` contract is a hardcoded 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 using `transferFrom`.

## Example Code

1. ERC721 uses `tokenID` for almost all interactions with it. So we first convert our `NFTID` to a `tokenID`:
1. ERC721 uses the `tokenID` for almost all interactions with it. So first, you should convert the `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)`.
You can use the ISCTypes.asNFTID() function to convert a Token ID to an NFT ID, by either using it on a token ID `tokenID.asNFTID();` or passing it to function `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
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);
Expand Down

0 comments on commit b1876d5

Please sign in to comment.