Post
Share your knowledge.
+15
Xavier.eth301
Jun 17, 2025
Expert Q&A
How do ability constraints interact with dynamic fields in heterogeneous collections?
I'm building a marketplace that needs to handle multiple asset types with different ability requirements, and I've hit some fundamental questions about Move's type system. I want to store different asset types in the same collection, but they have different abilities:
- Regular NFTs:
key + store
(transferable) - Soulbound tokens:
key
only (non-transferable) - Custom assets with transfer restrictions
public struct Marketplace has key {
id: UID,
listings: Bag, // Want to store different asset types here
}
// This works for transferable assets
public fun list_transferable<T: key + store>(
marketplace: &mut Marketplace,
asset: T,
price: u64
) { /* ... */ }
// But how to handle soulbound assets?
public fun list_soulbound<T: key>( // No store ability
marketplace: &mut Marketplace,
asset_ref: &T, // Can only take reference
price: u64
) { /* How do I store metadata about this? */ }
Key Questions:
- Ability Requirements: When using
dynamic_field::add<K, V>()
, doesV
always needstore
at compile time? Can wrapper types work around this? - Heterogeneous Storage: Can a single Bag store objects with different ability sets (
key + store + copy
vskey + store
), and handle them differently at runtime? - Type Safety: Since dynamic fields perform type erasure, how do I maintain type safety when retrieving values? What's the pattern for storing type metadata?
- Witness Pattern: How do ability constraints work with phantom types? Can I store
Asset<Type1>
andAsset<Type2>
in the same collection and extract type info later?
Building a system where NFTs, soulbound tokens, and restricted assets all need marketplace functionality but with different transfer semantics.
I’ve tried wrapper types, multiple collections per ability set, separate type metadata storage. Each has tradeoffs between type safety, gas costs, and complexity.
- Sui
- Architecture
0
0
Share
Comments
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
325Posts469Answers

Reward CampaignJune
- Owen... SUI+137
1
- 0xduckmove... SUI+55
2
- MoonBags... SUI+50
3
- ... SUIdudley_smith+31
- ... SUI
- ... SUIderiss+15
- ... SUIPluto Dev👽+10
- ... SUIDominikus +10
- ... SUIandreweth.+10
- ... SUIfarshad+10
Bounty Posts