From 251a87c0571fe15bd7a23ec25e8ebe8c785c7254 Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Tue, 23 Jul 2024 17:51:09 +0530 Subject: [PATCH 1/7] Add comments in the contract --- .../how-tos/core-contracts/nft/mint-nft.md | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md index d889d7972a2..62dc37c5525 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md @@ -88,15 +88,27 @@ pragma solidity ^0.8.0; import "@iota/iscmagic/ISC.sol"; contract NFTContract { + // Event emitted when a new NFT is minted event MintedNFT(bytes mintID); + /** + * @notice Mints a new NFT with the provided metadata and storage deposit + * @param _name The name of the NFT + * @param _mimeType The MIME type of the NFT + * @param _uri The URI where the NFT data is stored + * @param _storageDeposit The amount of storage deposit required + */ function mintNFT(string memory _name, string memory _mimeType, string memory _uri, uint64 _storageDeposit) public payable { require(msg.value == _storageDeposit*(10**12), "Please send exact funds to pay for storage deposit"); + + // Create an ISCAssets object for the allowance with the base tokens ISCAssets memory allowance; allowance.baseTokens = _storageDeposit; + // Retrieve the sender's account ID ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); + // Create the metadata for the NFT IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ standard: "IRC27", version: "v1.0", @@ -105,31 +117,49 @@ contract NFTContract { name: _name }); + // Prepare the parameters dictionary for the ISC call ISCDict memory params = ISCDict(new ISCDictItem[](2)); params.items[0] = ISCDictItem("I", bytes(IRC27NFTMetadataToString(metadata))); params.items[1] = ISCDictItem("a", agentID.data); + // Call the ISC sandbox to mint the NFT ISCDict memory ret = ISC.sandbox.call( ISC.util.hn("accounts"), ISC.util.hn("mintNFT"), params, allowance ); + + // Emit the MintedNFT event with the returned mint ID emit MintedNFT(ret.items[0].value); } + /** + * @notice Retrieves the NFT ID associated with a given mint ID + * @param mintID The mint ID of the NFT + * @return The NFT ID associated with the provided mint ID + */ function getNFTIDFromMintID(bytes memory mintID) public view returns (bytes memory) { + // Prepare the parameters dictionary for the ISC call ISCDict memory params = ISCDict(new ISCDictItem[](1)); params.items[0] = ISCDictItem("D", mintID); + // Call the ISC sandbox to get the NFT ID ISCDict memory ret = ISC.sandbox.callView( ISC.util.hn("accounts"), ISC.util.hn("NFTIDbyMintID"), params ); + + // Return the NFT ID return ret.items[0].value; } + /** + * @notice Converts an IRC27NFTMetadata struct to a JSON string + * @param metadata The metadata to convert + * @return The JSON string representation of the metadata + */ function IRC27NFTMetadataToString(IRC27NFTMetadata memory metadata) public pure @@ -149,4 +179,5 @@ contract NFTContract { '"}'); } } + ``` From 9a71d5f613bff55cac5452b9226edfa631c46349 Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Wed, 24 Jul 2024 15:02:00 +0530 Subject: [PATCH 2/7] Add admonitions in the doc --- .../isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md index 62dc37c5525..b9a04f92bbb 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md @@ -22,9 +22,16 @@ The Stardust update allows you to create your own NFTs. You can also use [IRC27] ```solidity ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); ``` +:::info ISC AGENT ID +The `ISCAgentID` represents the identifier of the agent (user or contract) whose NFTs you want to retrieve. You can get the `AgentID` from the sender by calling `ISC.sandbox.getSenderAccount()`. +::: 3. Create an `IRC27Metadata` struct with all the needed data: +:::tip +You can refer to [this](https://wiki.iota.org/isc/how-tos/core-contracts/nft/get-nft-metadata/) guide to understand how to create an `IRC27Metadata` +::: + ```solidity IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ standard: "IRC27", @@ -35,6 +42,7 @@ IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ }); ``` + 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 @@ -179,5 +187,4 @@ contract NFTContract { '"}'); } } - ``` From aa45111222b3605d6bf94d03caed107a3a9d8bbd Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Mon, 29 Jul 2024 12:08:37 +0530 Subject: [PATCH 3/7] Upgrade doc --- .../isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md index b9a04f92bbb..4c321921256 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md @@ -19,19 +19,20 @@ The Stardust update allows you to create your own NFTs. You can also use [IRC27] 2. Get the senders AgentID: +The `ISCAgentID` represents the identifier of the agent (user or contract) whose NFTs you want to retrieve. You can get the `AgentID` from the sender by calling `ISC.sandbox.getSenderAccount()`. + ```solidity ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); ``` -:::info ISC AGENT ID -The `ISCAgentID` represents the identifier of the agent (user or contract) whose NFTs you want to retrieve. You can get the `AgentID` from the sender by calling `ISC.sandbox.getSenderAccount()`. -::: 3. Create an `IRC27Metadata` struct with all the needed data: :::tip -You can refer to [this](https://wiki.iota.org/isc/how-tos/core-contracts/nft/get-nft-metadata/) guide to understand how to create an `IRC27Metadata` +You can refer to [Get NFT Metadata guide](https://wiki.iota.org/isc/how-tos/core-contracts/nft/get-nft-metadata/) to understand how to create an `IRC27Metadata` ::: +The`IRC27Metadata` struct in Solidity is designed to hold the metadata for a Non-Fungible Token (NFT) according to the IRC27 standard. This struct includes various fields that describe the NFT, such as its standard, version, MIME type, URI, and name. Here's how to create and use this struct: + ```solidity IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ standard: "IRC27", From d73189264de8442a65d39d99e21b268eddf55ae5 Mon Sep 17 00:00:00 2001 From: vivekjain23 <165671934+vivekjain23@users.noreply.github.com> Date: Wed, 31 Jul 2024 11:49:33 +0530 Subject: [PATCH 4/7] Update hyperlink Co-authored-by: Lucas Tortora <85233773+lucas-tortora@users.noreply.github.com> --- docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md index 4c321921256..63787cf5561 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md @@ -28,7 +28,7 @@ ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); 3. Create an `IRC27Metadata` struct with all the needed data: :::tip -You can refer to [Get NFT Metadata guide](https://wiki.iota.org/isc/how-tos/core-contracts/nft/get-nft-metadata/) to understand how to create an `IRC27Metadata` +You can refer to [Get NFT Metadata guide](get-nft-metadata.md) to understand how to create an `IRC27Metadata` ::: The`IRC27Metadata` struct in Solidity is designed to hold the metadata for a Non-Fungible Token (NFT) according to the IRC27 standard. This struct includes various fields that describe the NFT, such as its standard, version, MIME type, URI, and name. Here's how to create and use this struct: From 6cf224ed95e1627764a9838b1eb5b3783c5442ad Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Wed, 31 Jul 2024 13:21:39 +0530 Subject: [PATCH 5/7] Fix hyperlink --- .../how-tos/core-contracts/nft/mint-nft.md | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md index d889d7972a2..d69fe7b8153 100644 --- a/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md @@ -19,12 +19,20 @@ The Stardust update allows you to create your own NFTs. You can also use [IRC27] 2. Get the senders AgentID: +The `ISCAgentID` represents the identifier of the agent (user or contract) whose NFTs you want to retrieve. You can get the `AgentID` from the sender by calling `ISC.sandbox.getSenderAccount()`. + ```solidity ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); ``` 3. Create an `IRC27Metadata` struct with all the needed data: +:::tip +You can refer to [Get NFT Metadata guide](/isc/how-tos/core-contracts/nft/get-nft-metadata/) to understand how to create an `IRC27Metadata` +::: + +The`IRC27Metadata` struct in Solidity is designed to hold the metadata for a Non-Fungible Token (NFT) according to the IRC27 standard. This struct includes various fields that describe the NFT, such as its standard, version, MIME type, URI, and name. Here's how to create and use this struct: + ```solidity IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ standard: "IRC27", @@ -35,6 +43,7 @@ IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ }); ``` + 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 @@ -88,15 +97,27 @@ pragma solidity ^0.8.0; import "@iota/iscmagic/ISC.sol"; contract NFTContract { + // Event emitted when a new NFT is minted event MintedNFT(bytes mintID); + /** + * @notice Mints a new NFT with the provided metadata and storage deposit + * @param _name The name of the NFT + * @param _mimeType The MIME type of the NFT + * @param _uri The URI where the NFT data is stored + * @param _storageDeposit The amount of storage deposit required + */ function mintNFT(string memory _name, string memory _mimeType, string memory _uri, uint64 _storageDeposit) public payable { require(msg.value == _storageDeposit*(10**12), "Please send exact funds to pay for storage deposit"); + + // Create an ISCAssets object for the allowance with the base tokens ISCAssets memory allowance; allowance.baseTokens = _storageDeposit; + // Retrieve the sender's account ID ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); + // Create the metadata for the NFT IRC27NFTMetadata memory metadata = IRC27NFTMetadata({ standard: "IRC27", version: "v1.0", @@ -105,31 +126,49 @@ contract NFTContract { name: _name }); + // Prepare the parameters dictionary for the ISC call ISCDict memory params = ISCDict(new ISCDictItem[](2)); params.items[0] = ISCDictItem("I", bytes(IRC27NFTMetadataToString(metadata))); params.items[1] = ISCDictItem("a", agentID.data); + // Call the ISC sandbox to mint the NFT ISCDict memory ret = ISC.sandbox.call( ISC.util.hn("accounts"), ISC.util.hn("mintNFT"), params, allowance ); + + // Emit the MintedNFT event with the returned mint ID emit MintedNFT(ret.items[0].value); } + /** + * @notice Retrieves the NFT ID associated with a given mint ID + * @param mintID The mint ID of the NFT + * @return The NFT ID associated with the provided mint ID + */ function getNFTIDFromMintID(bytes memory mintID) public view returns (bytes memory) { + // Prepare the parameters dictionary for the ISC call ISCDict memory params = ISCDict(new ISCDictItem[](1)); params.items[0] = ISCDictItem("D", mintID); + // Call the ISC sandbox to get the NFT ID ISCDict memory ret = ISC.sandbox.callView( ISC.util.hn("accounts"), ISC.util.hn("NFTIDbyMintID"), params ); + + // Return the NFT ID return ret.items[0].value; } + /** + * @notice Converts an IRC27NFTMetadata struct to a JSON string + * @param metadata The metadata to convert + * @return The JSON string representation of the metadata + */ function IRC27NFTMetadataToString(IRC27NFTMetadata memory metadata) public pure From 80919e16c72e39f691a5febd676adb09fcaa8a25 Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Wed, 31 Jul 2024 14:09:05 +0530 Subject: [PATCH 6/7] fix checks From 11957299bb2bc361a0fbf8a7be96e8899e780eef Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Wed, 31 Jul 2024 16:30:08 +0530 Subject: [PATCH 7/7] Fix netspec comments in contract and hyperlinks --- .../how-tos/core-contracts/nft/mint-nft.md | 36 +++++++++---------- .../how-tos/core-contracts/nft/mint-nft.md | 34 +++++++++--------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md index 63787cf5561..d8f5b3b002d 100644 --- a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/mint-nft.md @@ -28,7 +28,7 @@ ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); 3. Create an `IRC27Metadata` struct with all the needed data: :::tip -You can refer to [Get NFT Metadata guide](get-nft-metadata.md) to understand how to create an `IRC27Metadata` +You can refer to [Get NFT Metadata guide](/isc/how-tos/core-contracts/nft/get-nft-metadata/) to understand how to create an `IRC27Metadata` ::: The`IRC27Metadata` struct in Solidity is designed to hold the metadata for a Non-Fungible Token (NFT) according to the IRC27 standard. This struct includes various fields that describe the NFT, such as its standard, version, MIME type, URI, and name. Here's how to create and use this struct: @@ -100,13 +100,13 @@ contract NFTContract { // Event emitted when a new NFT is minted event MintedNFT(bytes mintID); - /** - * @notice Mints a new NFT with the provided metadata and storage deposit - * @param _name The name of the NFT - * @param _mimeType The MIME type of the NFT - * @param _uri The URI where the NFT data is stored - * @param _storageDeposit The amount of storage deposit required - */ + + /// @notice Mints a new NFT with the provided metadata and storage deposit + /// @param _name The name of the NFT + /// @param _mimeType The MIME type of the NFT + /// @param _uri The URI where the NFT data is stored + /// @param _storageDeposit The amount of storage deposit required + function mintNFT(string memory _name, string memory _mimeType, string memory _uri, uint64 _storageDeposit) public payable { require(msg.value == _storageDeposit*(10**12), "Please send exact funds to pay for storage deposit"); @@ -143,11 +143,11 @@ contract NFTContract { emit MintedNFT(ret.items[0].value); } - /** - * @notice Retrieves the NFT ID associated with a given mint ID - * @param mintID The mint ID of the NFT - * @return The NFT ID associated with the provided mint ID - */ + + /// @notice Retrieves the NFT ID associated with a given mint ID + /// @param mintID The mint ID of the NFT + /// @return The NFT ID associated with the provided mint ID + function getNFTIDFromMintID(bytes memory mintID) public view returns (bytes memory) { // Prepare the parameters dictionary for the ISC call ISCDict memory params = ISCDict(new ISCDictItem[](1)); @@ -164,11 +164,11 @@ contract NFTContract { return ret.items[0].value; } - /** - * @notice Converts an IRC27NFTMetadata struct to a JSON string - * @param metadata The metadata to convert - * @return The JSON string representation of the metadata - */ + + /// @notice Converts an IRC27NFTMetadata struct to a JSON string + /// @param metadata The metadata to convert + /// @return The JSON string representation of the metadata + function IRC27NFTMetadataToString(IRC27NFTMetadata memory metadata) public pure diff --git a/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md index d69fe7b8153..d8f5b3b002d 100644 --- a/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md +++ b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/mint-nft.md @@ -100,13 +100,13 @@ contract NFTContract { // Event emitted when a new NFT is minted event MintedNFT(bytes mintID); - /** - * @notice Mints a new NFT with the provided metadata and storage deposit - * @param _name The name of the NFT - * @param _mimeType The MIME type of the NFT - * @param _uri The URI where the NFT data is stored - * @param _storageDeposit The amount of storage deposit required - */ + + /// @notice Mints a new NFT with the provided metadata and storage deposit + /// @param _name The name of the NFT + /// @param _mimeType The MIME type of the NFT + /// @param _uri The URI where the NFT data is stored + /// @param _storageDeposit The amount of storage deposit required + function mintNFT(string memory _name, string memory _mimeType, string memory _uri, uint64 _storageDeposit) public payable { require(msg.value == _storageDeposit*(10**12), "Please send exact funds to pay for storage deposit"); @@ -143,11 +143,11 @@ contract NFTContract { emit MintedNFT(ret.items[0].value); } - /** - * @notice Retrieves the NFT ID associated with a given mint ID - * @param mintID The mint ID of the NFT - * @return The NFT ID associated with the provided mint ID - */ + + /// @notice Retrieves the NFT ID associated with a given mint ID + /// @param mintID The mint ID of the NFT + /// @return The NFT ID associated with the provided mint ID + function getNFTIDFromMintID(bytes memory mintID) public view returns (bytes memory) { // Prepare the parameters dictionary for the ISC call ISCDict memory params = ISCDict(new ISCDictItem[](1)); @@ -164,11 +164,11 @@ contract NFTContract { return ret.items[0].value; } - /** - * @notice Converts an IRC27NFTMetadata struct to a JSON string - * @param metadata The metadata to convert - * @return The JSON string representation of the metadata - */ + + /// @notice Converts an IRC27NFTMetadata struct to a JSON string + /// @param metadata The metadata to convert + /// @return The JSON string representation of the metadata + function IRC27NFTMetadataToString(IRC27NFTMetadata memory metadata) public pure