Artinals Protocol
  • Introduction
    • What is Artinals?
    • Overview of the Modules
    • Key Concepts and Terminology
  • Getting Started
    • Prerequisites
    • Cloning the Repository
    • Building and Testing the Modules
  • ART20
    • Overview and Capabilities
    • Data Structures
      • NFT
      • CollectionCap
      • UserBalance
      • TokenIdCounter
      • Dual IDs
    • Events
      • NFTMintedEvent
      • CollectionCreatedEvent
      • MetadataUpdateEvent
      • BurnEvent
      • TransferEvent
      • Additional Events
    • Functions and Entry Points
      • Initializing the Module
      • Creating Collections
      • Minting ART20 NFTs
      • Updating Metadata
      • Transfer and Burn Operations
      • Batch Operations
      • Deny List Mechanics and Authority
      • Custom Transfers
    • Value Sources (API, Oracle)
    • Best Practices & Examples
  • SALE Module
    • Purpose and Functionality
    • Interdependence
    • Price Index Module
    • Liquidity Module
    • Data Structures
      • NFTSale
      • NFTListing
  • Events
    • SaleCreated
    • NFTPurchased
    • PriceUpdateEvent
    • CurrencyWithdrawn
    • DenyList & Related Events
    • PoolCreatedEvent
    • OrderCanceled
    • OrderExecuted
  • Functions and Entry Points
    • Creating a Sale
    • Adding NFTs to a Sale
    • Purchasing NFTs from a Sale
    • Withdrawing Proceeds
    • Managing Sale State
    • Core Trading Functionality
  • Integrating with ART20
  • Examples & Best Practices
  • MARKET Module
    • Introduction
    • Testnet (Beta)
    • Smart Contract Overview
    • Data Structures
      • Trade Ledger (TradeLedger)
      • Trade Offer (TradeOffer)
      • Buy Offer (BuyOffer)
      • Ledger Registry (LedgerRegistry)
    • Event Structures
      • Offer Created (OfferCreated)
      • Offer Accepted (OfferAccepted)
      • Buy Offer Created (BuyOfferCreated)
      • Buy Offer Accepted (BuyOfferAccepted)
      • Batch Transactions
    • Event Emissions
    • Functions and Entry Points
      • Trade Ledger Management
      • Register Ledger
      • Get Trade Ledger
      • Create Sell Offer
      • Accept Sell Offer
      • Cancel Sell Offer
      • Create Buy Offer
      • Accept Buy Offer
      • Cancel Buy Offer
      • Batch Accept Sell Offers
      • Batch Accept Buy Offers
  • Security Mechanisms
  • TRADE Module
    • Introduction
    • Purpose and Ecosystem Role
    • Data Structures
      • TradingPool
      • LiquidityPosition
      • PriceOracle
      • CollectionPool
    • Events
      • PoolCreated
      • LiquidityAdded
      • LiquidityRemoved
      • TradeExecuted
      • PoolStatusChanged
      • PoolFeesUpdated
    • Functions and Entry Points
      • Creating and Managing Liquidity Pools
      • Adding/Removing Liquidity
      • Swapping NFTs and Tokens
      • Fee Mechanics and Distribution
      • Emergency Operations and Recovery
  • Working with Price Oracles
  • Metrics and Statistics (24h Volumes, TWAP, Price Impact)
  • Integration with SALE and ART20
  • Integration and Workflows
    • Typical User Journeys
      • Creating a Collection and Minting Tokens (ART20)
      • Listing and Selling NFTs (SALE)
      • Providing Liquidity and Trading NFTs (TRADE)
    • Example Scripts and Transactions
    • Interactions Between Modules
  • Security, Permissions, and Deny Lists
    • Introduction
    • Role of Deny List in ART20
    • Creator vs. Owner Permissions
    • Fee Distribution and Authority
    • Best Practices for Secure Deployment
  • Testing and Troubleshooting
    • Running Unit Tests
    • Common Issues and Solutions
    • Debugging and Emitting Debug Events
  • Advanced Topics
    • Value Sources (API Endpoints and Oracle Addresses)
    • Batch Update Operations
    • Customizing Parameters (Fees, Supply, Price Ranges)
    • Extensibility and Future Integrations
  • Appendices
    • Move Language and Sui Concepts
    • Glossary of Terms
    • Code Style and Conventions
  • Building on Top of the Artinals Contract
    • Overview
    • Package ID
    • Import Modules
    • Commom Integration Patterns
    • Best Practices
    • Common Errors and Solutions
Powered by GitBook
On this page
  1. ART20
  2. Data Structures

Dual IDs

In the ART20 module, each NFT is associated with two key identifiers that together provide a robust and flexible way to reference and manage tokens:

  1. Object ID (UID): Every NFT is represented as an on-chain object in Sui, and like any Sui object, it has a unique Object ID (UID). This UID is a low-level, globally unique identifier assigned by the Sui runtime when the NFT object is created. It is essential for performing transactions on that specific object—such as transferring, burning, or updating it—and serves as the foundational reference for all Move function calls that operate on the NFT.

  2. Asset ID (Collection-Scoped ID): Beyond the global Object ID, ART20 NFTs also have an asset_id, which uniquely identifies the NFT within its own collection. Unlike the Object ID, which is globally unique across the entire blockchain, the asset_id is scoped to a single collection. This approach makes it easier to reason about NFTs at a collection level—for example, referring to "Token #1" or "Token #100" within a specific collection.

    The asset_id effectively serves as a "human-friendly" handle or an internal index for tokens in a particular collection. It can be used to:

    • Locate NFTs within the same collection quickly.

    • Batch update or transfer tokens based on their asset_id range.

    • Provide users with a simple reference point (“This is my #25 NFT in the collection.”).

Why Dual IDs?

  • Global vs. Local Context: The Object ID operates at a global context (the entire blockchain), which is crucial for smart contract operations. The asset_id gives a localized context, making it easier to interact with tokens in bulk or refer to them by simple integers within a known set.

  • User Experience: Collection-level IDs (asset_ids) are more intuitive for users. Collectors and traders often identify NFTs by a number within a collection rather than a long hexadecimal Object ID. This improves the user experience when browsing, trading, or discussing NFTs.

  • Development and Integration: On the development side, working with asset_ids simplifies certain operations. For instance, performing batch metadata updates or implementing features like "update_art20_image_uri_by_asset_id" becomes more straightforward, as developers can iterate over a sequence of asset_ids instead of handling a set of unrelated global UIDs.

Example:

  • When an NFT is minted, it receives:

    • A globally unique id (UID) from Sui (e.g., 0x...abc123).

    • An asset_id within the collection (e.g., #42), incrementing as new NFTs are minted in that particular collection.

Best Practices with Dual IDs:

  • Use Object IDs (UIDs) for direct operations on specific NFT objects (transfers, updates).

  • Use asset_ids to group operations, run batch updates, or provide a user-facing numbering system.

  • Keep a clear mapping in your front-end or indexing layer between Object IDs and asset_ids. This allows you to easily display asset_ids to users while the backend logic still references object IDs for transactions.

By leveraging both the global Object ID and the collection-scoped asset_id, the ART20 module ensures a robust, intuitive, and developer-friendly framework for managing NFTs at both a technical and user-facing level.

PreviousTokenIdCounterNextEvents

Last updated 6 months ago