NftController Actions
8 actions registered.
| Name | Deprecated |
|---|---|
addNft | |
addNftVerifyOwnership | |
checkAndUpdateAllNftsOwnershipStatus | |
checkAndUpdateSingleNftOwnershipStatus | |
getState | |
isNftOwner | |
removeAndIgnoreNft | |
removeNft |
NftController:addNft
Package: @metamask/assets-controllers
Adds an NFT and respective NFT contract to the stored NFT and NFT contracts lists.
Parameters:
| Name | Description |
|---|---|
tokenAddress | Hex address of the NFT contract. |
tokenId | The NFT identifier. |
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
options | an object of arguments |
options.nftMetadata | NFT optional metadata. |
options.userAddress | The address of the current user. |
options.source | Whether the NFT was detected, added manually or suggested by a dapp. Defaults to Source.Custom; pass Source.Detected when refreshing existing NFTs. |
Returns: Promise resolving to the current NFT list.
Handler signature:
(tokenAddress: string, tokenId: string, networkClientId: NetworkClientId, { nftMetadata, userAddress, source, }?: {
nftMetadata?: NftMetadata;
userAddress?: string;
source?: Source;
}) => Promise<void>
NftController:addNftVerifyOwnership
Package: @metamask/assets-controllers
Verifies currently selected address owns entered NFT address/tokenId combo and adds the NFT and respective NFT contract to the stored NFT and NFT contracts lists.
Parameters:
| Name | Description |
|---|---|
address | Hex address of the NFT contract. |
tokenId | The NFT identifier. |
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
options | an object of arguments |
options.userAddress | The address of the current user. |
options.source | Whether the NFT was detected, added manually or suggested by a dapp. Defaults to Source.Custom; pass Source.Detected when refreshing existing NFTs. |
Handler signature:
(address: string, tokenId: string, networkClientId: NetworkClientId, { userAddress, source, }?: {
userAddress?: string;
source?: Source;
}) => Promise<void>
NftController:checkAndUpdateAllNftsOwnershipStatus
Package: @metamask/assets-controllers
Checks whether NFTs associated with current selectedAddress/chainId combination are still owned by the user And updates the isCurrentlyOwned value on each accordingly. Uses Multicall3 to batch all ownership checks into a single RPC request when available.
Parameters:
| Name | Description |
|---|---|
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
options | an object of arguments |
options.userAddress | The address of the account where the NFT ownership status is checked/updated. |
Handler signature:
(networkClientId: NetworkClientId, { userAddress, }?: {
userAddress?: string;
}) => Promise<void>
NftController:checkAndUpdateSingleNftOwnershipStatus
Package: @metamask/assets-controllers
Checks whether input NFT is still owned by the user and updates the isCurrentlyOwned value on the NFT object accordingly.
Parameters:
| Name | Description |
|---|---|
nft | The NFT object to check and update. |
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
accountParams | The userAddress to check ownership against. |
accountParams.userAddress | the address passed through the confirmed transaction flow to ensure assets are stored to the correct account |
Returns: the NFT with the updated isCurrentlyOwned value
Handler signature:
(nft: Nft, networkClientId: NetworkClientId, { userAddress }?: {
userAddress?: string;
}) => Promise<Nft>
NftController:getState
Package: @metamask/assets-controllers
Handler signature:
() => NftControllerState
NftController:isNftOwner
Package: @metamask/assets-controllers
Checks the ownership of a ERC-721 or ERC-1155 NFT for a given address.
Parameters:
| Name | Description |
|---|---|
ownerAddress | User public address. |
nftAddress | NFT contract address. |
tokenId | NFT token ID. |
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
options | Optional parameters. |
options.standard | The NFT standard ('ERC721' or 'ERC1155'). When provided, only the relevant ownership check is performed, halving the number of RPC subcalls. |
Returns: Promise resolving the NFT ownership.
Handler signature:
(ownerAddress: string, nftAddress: string, tokenId: string, networkClientId: NetworkClientId, { standard }?: {
standard?: string | null;
}) => Promise<boolean>
NftController:removeAndIgnoreNft
Package: @metamask/assets-controllers
Removes an NFT from the stored token list and saves it in ignored NFTs list.
Parameters:
| Name | Description |
|---|---|
address | Hex address of the NFT contract. |
tokenId | Token identifier of the NFT. |
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
options | an object of arguments |
options.userAddress | The address of the account where the NFT is being removed. |
Handler signature:
(address: string, tokenId: string, networkClientId: NetworkClientId, { userAddress }?: {
userAddress?: string;
}) => void
NftController:removeNft
Package: @metamask/assets-controllers
Removes an NFT from the stored token list.
Parameters:
| Name | Description |
|---|---|
address | Hex address of the NFT contract. |
tokenId | Token identifier of the NFT. |
networkClientId | The networkClientId that can be used to identify the network client to use for this request. |
options | an object of arguments |
options.userAddress | The address of the account where the NFT is being removed. |
Handler signature:
(address: string, tokenId: string, networkClientId: NetworkClientId, { userAddress }?: {
userAddress?: string;
}) => void