diff --git a/docs/build/isc/v1.1/docs/_admonitions/_AgentID.md b/docs/build/isc/v1.1/docs/_admonitions/_AgentID.md new file mode 100644 index 00000000000..b3cfe6421fd --- /dev/null +++ b/docs/build/isc/v1.1/docs/_admonitions/_AgentID.md @@ -0,0 +1,5 @@ +:::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`](../explanations/how-accounts-work.md) from the sender by calling `ISC.sandbox.getSenderAccount()`. + +::: \ No newline at end of file diff --git a/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx new file mode 100644 index 00000000000..1ad194eed48 --- /dev/null +++ b/docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx @@ -0,0 +1,53 @@ +--- +description: How to get the L2 NFTs owned by an account. +image: /img/logo/WASP_logo_dark.png +tags: + - EVM + - how-to + - native tokens + - L2 NFTs +--- +import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md'; +import ISCAgentID from '../../../_admonitions/_AgentID.md'; + +# Get NFTs Owned by an Account + +This guide will show you how to get the L2 NFTs owned by an account using the [`ISCAccounts.getL2NFTs`](../../../reference/magic-contract/ISCAccounts.md#getl2nfts) function from the [`ISCAccounts`](../../../reference/magic-contract/ISCAccounts.md) [magic contract](../../../reference/magic-contract/introduction.md). + + +## Understanding the `getL2NFTs` Function + +The `getL2NFTs` function is a view function provided by the `ISCAccounts` interface. It takes an `ISCAgentID` as an argument and returns an array of `NFTID` objects. This function allows users to query and retrieve the list of L2 NFTs owned by a specified agent. + + +The returned array contains the identifiers of the NFTs, which can then be used to fetch more details about each NFT if needed. + +## Implement the `getL2NFTs` Function + +Here’s a sample implementation to retrieve L2 NFTs owned by an account: + +```solidity +function getOwnedNFTs(ISCAgentID memory agentID) public view returns (NFTID[] memory) { + // Call the getL2NFTs function from the ISCAccounts contract + NFTID[] memory ownedNFTs = ISC.accounts.getL2NFTs(agenID); + return ownedNFTs; +} +``` + +## Full Example Contract + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +import "@iota/iscmagic/ISC.sol"; + +contract MyNFTContract { + +function getOwnedNFTs(ISCAgentID memory agentID) public view returns (NFTID[] memory) { + // Call the getL2NFTs function from the ISCAccounts contract + NFTID[] memory ownedNFTs = ISC.accounts.getL2NFTs(agenID); + return ownedNFTs; + } +} +``` \ 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 675779b89b5..89aa93d081d 100644 --- a/docs/build/isc/v1.1/sidebars.js +++ b/docs/build/isc/v1.1/sidebars.js @@ -215,6 +215,11 @@ module.exports = { label: 'Get NFT Metadata', id: 'how-tos/core-contracts/nft/get-nft-metadata', }, + { + type: 'doc', + label: 'Get NFTs Owned by an Account', + id: 'how-tos/core-contracts/nft/get-L2-nfts', + }, ], }, { diff --git a/docs/build/isc/v1.3/docs/_admonitions/_AgentID.md b/docs/build/isc/v1.3/docs/_admonitions/_AgentID.md new file mode 100644 index 00000000000..b3cfe6421fd --- /dev/null +++ b/docs/build/isc/v1.3/docs/_admonitions/_AgentID.md @@ -0,0 +1,5 @@ +:::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`](../explanations/how-accounts-work.md) from the sender by calling `ISC.sandbox.getSenderAccount()`. + +::: \ No newline at end of file diff --git a/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx new file mode 100644 index 00000000000..1ad194eed48 --- /dev/null +++ b/docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx @@ -0,0 +1,53 @@ +--- +description: How to get the L2 NFTs owned by an account. +image: /img/logo/WASP_logo_dark.png +tags: + - EVM + - how-to + - native tokens + - L2 NFTs +--- +import GetNftMetadata from '../../../_partials/how-tos/token/_get-nft-metadata.md'; +import ISCAgentID from '../../../_admonitions/_AgentID.md'; + +# Get NFTs Owned by an Account + +This guide will show you how to get the L2 NFTs owned by an account using the [`ISCAccounts.getL2NFTs`](../../../reference/magic-contract/ISCAccounts.md#getl2nfts) function from the [`ISCAccounts`](../../../reference/magic-contract/ISCAccounts.md) [magic contract](../../../reference/magic-contract/introduction.md). + + +## Understanding the `getL2NFTs` Function + +The `getL2NFTs` function is a view function provided by the `ISCAccounts` interface. It takes an `ISCAgentID` as an argument and returns an array of `NFTID` objects. This function allows users to query and retrieve the list of L2 NFTs owned by a specified agent. + + +The returned array contains the identifiers of the NFTs, which can then be used to fetch more details about each NFT if needed. + +## Implement the `getL2NFTs` Function + +Here’s a sample implementation to retrieve L2 NFTs owned by an account: + +```solidity +function getOwnedNFTs(ISCAgentID memory agentID) public view returns (NFTID[] memory) { + // Call the getL2NFTs function from the ISCAccounts contract + NFTID[] memory ownedNFTs = ISC.accounts.getL2NFTs(agenID); + return ownedNFTs; +} +``` + +## Full Example Contract + +```solidity +// SPDX-License-Identifier: MIT +pragma solidity >=0.8.24; + +import "@iota/iscmagic/ISC.sol"; + +contract MyNFTContract { + +function getOwnedNFTs(ISCAgentID memory agentID) public view returns (NFTID[] memory) { + // Call the getL2NFTs function from the ISCAccounts contract + NFTID[] memory ownedNFTs = ISC.accounts.getL2NFTs(agenID); + return ownedNFTs; + } +} +``` \ 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 675779b89b5..89aa93d081d 100644 --- a/docs/build/isc/v1.3/sidebars.js +++ b/docs/build/isc/v1.3/sidebars.js @@ -215,6 +215,11 @@ module.exports = { label: 'Get NFT Metadata', id: 'how-tos/core-contracts/nft/get-nft-metadata', }, + { + type: 'doc', + label: 'Get NFTs Owned by an Account', + id: 'how-tos/core-contracts/nft/get-L2-nfts', + }, ], }, {