🏴☠️ Architecture
This document introduces the overall architecture design of the ArtFlip platform.
System Architecture Overview
ArtFlip adopts a decentralized architecture, implementing NFT issuance, trading, and liquidity management based on smart contracts.
Core Components
1. Smart Contract Layer
Factory Contract
- Responsible for creating and managing NFT projects
- Handles project initialization parameters
- Manages project registry
ArtFlip Contract
- Implements the Bonding Curve algorithm
- Handles NFT minting and trading
- Manages trading pool and liquidity
Registry Contract
- Maintains project registration information
- Provides project query interfaces
- Manages project metadata
Trade Contract
- Handles NFT buy and sell transactions
- Calculates dynamic prices
- Manages trading pool
FeeVault Contract
- Manages platform fees
- Handles royalty distribution
- Fee withdrawal and distribution
2. Cross-chain Components
ZetaChain Integration
- Implements cross-chain NFT transfers
- Supports multi-chain interactions
- Cross-chain message passing
Superchain-ERC721 Standard
- Unified cross-chain NFT standard
- Enables seamless experience within the SuperChain ecosystem
3. Frontend Application Layer
Web Interface
- User interaction interface
- Wallet connection
- Trading operation interface
API Services
- Backend API services
- WebSocket gateway
- Real-time data push
4. Data Layer
The Graph Subgraph
- Indexes on-chain data
- Provides GraphQL query interfaces
- Real-time data synchronization
Technology Stack
Smart Contracts
- Solidity: Primary programming language
- Hardhat/Foundry: Development framework
- OpenZeppelin: Secure contract library
Frontend
- Next.js: Web application framework
- React: UI library
- Wagmi: Ethereum React Hooks
Backend
- NestJS: Node.js framework
- WebSocket: Real-time communication
Data Indexing
- The Graph: Decentralized indexing protocol
Data Flow
NFT Minting Flow
- User initiates minting request through frontend
- Frontend calls smart contract
- Bonding Curve algorithm calculates price
- User confirms and pays
- NFT minting completed
- Events triggered, Subgraph indexes data
- Frontend updates display
NFT Trading Flow
- User selects NFT to sell
- Smart contract calculates selling price
- NFT enters trading pool
- Other users can purchase directly
- Transaction completed, royalties automatically distributed
- Data synchronized and updated
Security Mechanisms
Smart Contract Security
- Code audits
- Use of verified libraries
- Upgrade mechanisms
Access Control
- Role-based permission management
- Multi-signature wallet support
- Timelock mechanisms
Scalability
Horizontal Scaling
- Support for multi-chain deployment
- Cross-chain interoperability
- Modular design
Performance Optimization
- Gas optimization
- Batch operation support
- Caching mechanisms
Future Plans
- Support for more EVM-compatible chains
- Enhanced cross-chain functionality
- Improved user experience
- New feature additions