Skip to content

XCM NFT: pallet-nfts Westend Asset Hub#9537

Open
mrshiposha wants to merge 14 commits intoparitytech:masterfrom
UniqueNetwork:xcm-nft-pallet-nfts
Open

XCM NFT: pallet-nfts Westend Asset Hub#9537
mrshiposha wants to merge 14 commits intoparitytech:masterfrom
UniqueNetwork:xcm-nft-pallet-nfts

Conversation

@mrshiposha
Copy link
Contributor

Description

This PR implements the new NFT traits from #5620 for pallet-nfts and uses the XCM NFT utilities from #4300 to add the corresponding Asset Transactors to the Westend Asset Hub.

Also, the pallet-nfts instance is made a host for derivative NFTs in Westend AH using the pallet-derivatives instances.

pallet-nfts was chosen to host the NFT derivatives instead of pallet-uniques for the following reasons:

  • pallet-nfts is a newer and more feature-rich pallet. Thus, dApps will likely choose to work with it rather than with pallet-uniques. It would be easier for dApps to support exactly one pallet to work with all the NFTs instead of supporting two different pallets (pallet-nfts and pallet-uniques).
  • Only pallet-nfts has an integration with pallet-nft-fractionalization. This means only its tokens can be fractionalized. So, if derivative NFTs are deployed there, they can be fractionalized as well.

pallet-nfts NFT XCM-related peculiarities

Avoiding losing NFTs metadata

Usually, XCM burns the asset when executing WithdrawAsset, and then mints it when executing DepositAsset.

However, this approach can't be used for pallet-nfts.
pallet-nfts might save the metadata when an NFT is burned. However, it doesn't always do this. If an NFT has the UnlockMetadata setting set, the metadata will be cleared when the token is destroyed.

So, to preserve the NFT metadata in all cases, the pallet-nfts transactor transfers the NFT to the Treasury on withdrawal and transfers from the Treasury on depositing.

Reusing the existing pallet-nfts instance for derivatives

We can't host another pallet-nfts with CollectionId = AssetId and ItemId = AssetInstance for derivative NFTs (similar to pallet-assets) since CollectionId must satisfy the Incrementable bound.

Also, if we were to create a separate pallet-nfts instance for derivatives, we wouldn't be able to use the existing integration with the pallet-nft-fractionalization on Westend AH for derivative NFTs.

Thus, to support the NFT derivatives, two instances of pallet-derivatives were added: 1) DerivativeNftCollections for registering the NFT collections and storing the mapping between XCM AssetId and CollectionId; 2) DerivativeNfts for holding the mapping between the XCM NFT ID and the local NFT ID.

Review Notes

  • New NFT traits implementation for pallet-nfts: <pallet-nfts-src>/asset_ops/{collection,item}.rs.
  • pallet-nfts related asset strategies are added to the <pallet-nfts-src>/types.rs into the asset_strategies module.
  • The corresponding tests are added to the existing tests.rs.
  • Westend AH's XCM config is modified to support pallet-nfts' tokens (including the derivative ones).
  • Relevant Westend AH's XCM tests are added.
  • Minor fix: pallet-derivatives path in the workspace Cargo.toml

Questions and TODOs

  • What is the best origin to register a derivative NFT collection? Currently, it is set to GeneralAdmin and seems rather limiting. May we lower the origin requirements (maybe even down to just EnsureSigned) at least for the testnets until a standard XCM way of registering derivative collections is devised? Lowering the origin requirements would greatly simplify experimenting with XCM NFTs on testnets.
  • TODO: benchmark pallet-derivatives for Westend Asset Hub

@mrshiposha mrshiposha requested review from a team as code owners August 21, 2025 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T6-XCM This PR/Issue is related to XCM.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants