diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-nft-in-collection.mdx b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-nft-in-collection.mdx new file mode 100644 index 00000000000..4bd64dac9df --- /dev/null +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-nft-in-collection.mdx @@ -0,0 +1,55 @@ +--- +description: How to get the L2 NFTs in a collection. +image: /img/logo/WASP_logo_dark.png +tags: + - EVM + - how-to + - native tokens + - L2 NFTs + - Collection +--- +import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md'; + +# Get NFTs of a Given Collection + +This guide will show you how to get the L2 NFTs of a given collection owned by an account using the [`ISCAccounts.getL2NFTsInCollection`](../../../reference/magic-contract/ISCAccounts.md#getl2nftsincollection) function from the [`ISCAccounts`](../../../reference/magic-contract/ISCAccounts.md) [magic contract](../../../reference/magic-contract/introduction.md). + + +## Implement the `getL2NFTsInCollection` Function + +Here’s a sample implementation to retrieve L2 NFTs within a specific collection owned by an account: + +```solidity +function getNFTsInCollection(NFTID memory collectionId) public view returns (NFTID[] memory) { + // Get the ISCAgentID + ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); + + // Call the getL2NFTsInCollection function from the ISCAccounts contract + NFTID[] memory nftsInCollection = ISC.accounts.getL2NFTsInCollection(agentID, collectionId); + + return nftsInCollection; +} +``` + +## Full Example Contract + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +import "@iota/iscmagic/ISCAccounts.sol"; +import "@iota/iscmagic/ISCSandbox.sol"; + +contract MyNFTContract { + +function getNFTsInCollection(NFTID memory collectionId) public view returns (NFTID[] memory) { + // Get the ISCAgentID + ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); + + // Call the getL2NFTsInCollection function from the ISCAccounts contract + NFTID[] memory nftsInCollection = ISC.accounts.getL2NFTsInCollection(agentID, collectionId); + + return nftsInCollection; + } +} +``` \ No newline at end of file diff --git a/docs/build/isc/v1.1/sidebars.js b/docs/build/isc/v1.1/sidebars.js index 89aa93d081d..6e93e225937 100644 --- a/docs/build/isc/v1.1/sidebars.js +++ b/docs/build/isc/v1.1/sidebars.js @@ -220,6 +220,11 @@ module.exports = { label: 'Get NFTs Owned by an Account', id: 'how-tos/core-contracts/nft/get-L2-nfts', }, + { + type: 'doc', + label: 'Get NFTs in Collection', + id: 'how-tos/core-contracts/nft/get-nft-in-collection', + }, ], }, { diff --git a/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-nft-in-collection.mdx b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-nft-in-collection.mdx new file mode 100644 index 00000000000..4bd64dac9df --- /dev/null +++ b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-nft-in-collection.mdx @@ -0,0 +1,55 @@ +--- +description: How to get the L2 NFTs in a collection. +image: /img/logo/WASP_logo_dark.png +tags: + - EVM + - how-to + - native tokens + - L2 NFTs + - Collection +--- +import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md'; + +# Get NFTs of a Given Collection + +This guide will show you how to get the L2 NFTs of a given collection owned by an account using the [`ISCAccounts.getL2NFTsInCollection`](../../../reference/magic-contract/ISCAccounts.md#getl2nftsincollection) function from the [`ISCAccounts`](../../../reference/magic-contract/ISCAccounts.md) [magic contract](../../../reference/magic-contract/introduction.md). + + +## Implement the `getL2NFTsInCollection` Function + +Here’s a sample implementation to retrieve L2 NFTs within a specific collection owned by an account: + +```solidity +function getNFTsInCollection(NFTID memory collectionId) public view returns (NFTID[] memory) { + // Get the ISCAgentID + ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); + + // Call the getL2NFTsInCollection function from the ISCAccounts contract + NFTID[] memory nftsInCollection = ISC.accounts.getL2NFTsInCollection(agentID, collectionId); + + return nftsInCollection; +} +``` + +## Full Example Contract + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +import "@iota/iscmagic/ISCAccounts.sol"; +import "@iota/iscmagic/ISCSandbox.sol"; + +contract MyNFTContract { + +function getNFTsInCollection(NFTID memory collectionId) public view returns (NFTID[] memory) { + // Get the ISCAgentID + ISCAgentID memory agentID = ISC.sandbox.getSenderAccount(); + + // Call the getL2NFTsInCollection function from the ISCAccounts contract + NFTID[] memory nftsInCollection = ISC.accounts.getL2NFTsInCollection(agentID, collectionId); + + return nftsInCollection; + } +} +``` \ No newline at end of file diff --git a/docs/build/isc/v1.3/sidebars.js b/docs/build/isc/v1.3/sidebars.js index 89aa93d081d..6e93e225937 100644 --- a/docs/build/isc/v1.3/sidebars.js +++ b/docs/build/isc/v1.3/sidebars.js @@ -220,6 +220,11 @@ module.exports = { label: 'Get NFTs Owned by an Account', id: 'how-tos/core-contracts/nft/get-L2-nfts', }, + { + type: 'doc', + label: 'Get NFTs in Collection', + id: 'how-tos/core-contracts/nft/get-nft-in-collection', + }, ], }, {