-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Guide to get NFTs Owned by an Account
- Loading branch information
Showing
6 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()`. | ||
|
||
::: |
53 changes: 53 additions & 0 deletions
53
docs/build/isc/v1.1/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). | ||
<GetNftMetadata/> | ||
|
||
## 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. | ||
<ISCAgentID/> | ||
|
||
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; | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()`. | ||
|
||
::: |
53 changes: 53 additions & 0 deletions
53
docs/build/isc/v1.3/docs/how-tos/core-contracts/nft/get-L2-nfts.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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). | ||
<GetNftMetadata/> | ||
|
||
## 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. | ||
<ISCAgentID/> | ||
|
||
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; | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters