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. Building on Top of the Artinals Contract

Import Modules

Example Implementation

https://github.com/artfilabs/rewardsv1.git

Add Dependencies

Add the Artinals package to your Move.toml:

[package]
name = "your_package_name"
edition = "2024.beta"

[dependencies.Sui]
git = "https://github.com/MystenLabs/sui.git"
subdir = "crates/sui-framework/packages/sui-framework"
rev = "framework/testnet"

[dependencies.artinals]
git = "https://github.com/artfilabs/artinalsprotocolv1.git"
rev = "main"
subdir = "."


[addresses]
rewards = "0x0"


[dev-dependencies]
# none

[dev-addresses]
# none

2. Import Modules

In your Move contract, import the required modules:

use artinals::ART20;  // For core NFT functionality
use artinals::SALE;   // For NFT sales features
use artinals::TRADE;  // For trading pool operations


Example Usage:
use artinals::ART20::{Self, NFT, CollectionCap, UserBalance};

Core Features Integration

1. NFT Management (ART20)

module your_package::nft_manager {
    use artinals::ART20::{Self, NFT, CollectionCap};
    
    // Create new NFT collection
    public entry fun create_collection(
        name: vector<u8>,
        description: vector<u8>,
        initial_supply: u64,
        max_supply: u64,
        uri: vector<u8>,
        logo_uri: vector<u8>,
        is_mutable: bool,
        has_deny_list_authority: bool,
        counter: &mut TokenIdCounter,
        ctx: &mut TxContext
    ) {
        ART20::mint_art20(
            name, description, initial_supply, max_supply,
            uri, logo_uri, is_mutable, has_deny_list_authority,
            counter, ctx
        );
    }
}

2. Sales Integration (SALE)

module your_package::marketplace {
    use artinals::SALE;
    use artinals::ART20::{NFT, CollectionCap, UserBalance};
    
    // Create NFT sale
    public entry fun create_sale<CURRENCY: store>(
        nfts: vector<NFT>,
        nft_amount: u64,
        price_per_nft: u64,
        collection_cap: &mut CollectionCap,
        sender_balances: vector<UserBalance>,
        ctx: &mut TxContext
    ) {
        SALE::create_nft_sale<CURRENCY>(
            nfts,
            nft_amount,
            price_per_nft,
            // Additional metadata parameters...
            collection_cap,
            sender_balances,
            ctx
        );
    }
}

3. Trading Pool Integration (TRADE)

module your_package::trading {
    use artinals::TRADE;
    use artinals::ART20::{NFT, CollectionCap, UserBalance};
    
    // Create trading pool
    public entry fun create_pool<CURRENCY: store>(
        collection_pool: &mut TRADE::CollectionPool<CURRENCY>,
        collection_cap: &CollectionCap,
        initial_nfts: vector<NFT>,
        initial_tokens: Coin<CURRENCY>,
        user_balance: &mut UserBalance,
        fee_percent: u64,
        min_price: u64,
        max_price: u64,
        ctx: &mut TxContext
    ) {
        TRADE::create_pool<CURRENCY>(
            collection_pool,
            collection_cap,
            initial_nfts,
            initial_tokens,
            user_balance,
            fee_percent,
            min_price,
            max_price,
            ctx
        );
    }
}

PreviousPackage IDNextCommom Integration Patterns

Last updated 4 months ago