Nyvo Docs
  • Introduction
  • Overview
    • Mission
    • Vision
  • The Product
    • Key Features
      • AI-Powered Prompt Interface
      • Full-Stack dApp Generation
      • One-Click Deployment
      • High-Performance Blockchain Support
      • Customizable UI & Theming
      • Integration and Composability
      • Developer-Friendly Export and Extension
      • Built-in Wallet & Identity Solutions
    • Use Cases and Examples
      • DeFi and Token Launchpads
      • NFT Marketplaces and Games
      • DAOs and Governance Platforms
      • Social and Utility dApps
      • Enterprise and Real-World Asset Apps
  • How Nyvo works
    • 1. Natural Language Understanding
    • 2. Solution Planning
    • 3. Smart Contract Code Generation
    • 4. Automated Testing & Validation
    • 5. Frontend Generation
    • 6. User Review and Iteration
    • 7. Deployment to Blockchain
    • Conclusion
  • Platform Architecture
    • Nyvo Studio
    • AI Orchestration Engine
    • Code Generation Models
      • Smart Contract Generator
      • Frontend/UI Generator
      • Documentation & Instruction Generator
    • Template & Module Library
    • Compilation & Testing Sandbox
    • Hosting Infrastructure
    • Data Storage & Security
  • Developer Guide & API
    • Architectural Overview
      • Program Deployment
      • Wallet Interactions & Security
      • UI Binding to On-Chain Data
      • Integration with Solana Runtime
    • Building dApps with Nyvo: Step-by-Step Guide
      • 1. Define the dApp Prompt
      • 2. Configuration & Module Selection
      • 3. Program Generation and Deployment
      • 4. Front-End Generation and Binding
      • 5. Testing the dApp
      • 6. Deployment to Production
  • Supported dApp Modules
    • Staking Module
    • Marketplace Module
    • Launchpad Module
    • Governance Module
    • Other Utility Modules
  • API and Abstraction Layers
    • Smart Contract Abstraction
    • Transaction Management API
    • Front-End and UI Components
    • Security Considerations in the API
  • Infrastructure & Performance
    • Deterministic Address Derivation (PDAs)
    • Transaction Simulation and Compute Units
    • Solana Fee Model and Cost Prediction
  • Rent-Exemption and Storage Costs
  • Combining Modules and Cross-Program Interactions
  • Best Practices: Security, Testing, and Maintenance
  • Pricing & Revenue Projection
    • Target Market & Addressable Users
    • Pricing Model & Tiers
      • Freemium (Free Tier)
      • Premium (Subscription Tier)
      • Lifetime (One-Time Purchase)
    • User Adoption Forecast
    • Revenue Projections
    • Marketing & Acquisition Channels
    • Expansion Plans & Future Monetization
  • Prompt Engineering
    • Key Strategies for Effective Solana-Focused Prompts
      • Set the AI’s Role and Context Upfront
      • Be Clear and Specific in Your Request
      • Provide Context from Your Project
      • Structure Prompts for Both Code and Explanations
      • Take an Iterative Approach
    • Building a Prompt Library
    • Debugging and Refining AI Outputs
    • Examples for Common dApp Scenarios
      • Example 1: Staking Dashboard dApp
      • Example 2: NFT Marketplace / Platform
      • Example 3: Crowdfunding (Fundraising) dApp
    • Final Tips
  • Legal & Socials
    • The Nyvo Whitepaper
    • Legal Disclaimer
    • Socials
Powered by GitBook
On this page
  1. Prompt Engineering
  2. Examples for Common dApp Scenarios

Example 2: NFT Marketplace / Platform

PreviousExample 1: Staking Dashboard dAppNextExample 3: Crowdfunding (Fundraising) dApp

Last updated 1 month ago

CtrlK

Scenario: An NFT platform where users can list NFTs for sale, browse available NFTs, and purchase them – all on Solana.

Prompt Example:

markdownKopierenBearbeitenYou are a Solana blockchain and front-end expert. 

**Task:** Create a **Solana NFT marketplace dApp**. 

**Requirements:**
- **Solana Program (Rust/Anchor):** Write an Anchor program for an NFT marketplace. It should allow users to list an NFT for sale by specifying a price, and allow another user to buy it. Use the Metaplex token metadata standard for NFTs (i.e., ensure the program checks the NFT’s metadata/owner). Include instructions: `list_nft(token_account, price)`, `buy_nft(token_account)`. The `list_nft` instruction should create a listing (perhaps a PDA account for the listing with price, seller pubkey, NFT mint, etc.), and transfer the NFT to escrow (the program) or use a escrow token account. The `buy_nft` instruction should transfer SOL from buyer to seller and return the NFT to the buyer. Include safety checks: only the NFT owner can list, only one listing per NFT at a time, etc.
- **Front-End (React/TypeScript):** Build a web UI where users can connect their Solana wallet to view listed NFTs and their details (image, price, seller). Provide a form to list an NFT (the user inputs the NFT mint address and price, then calls `list_nft`). Also provide a "Buy" button on each listed NFT that triggers the `buy_nft` transaction. Use @solana/web3.js or Anchor’s provider to interact with the program. Update the UI state after transactions (e.g., remove sold items, show the NFT in the buyer’s collection).
- **Integration:** Use a library or SDK to fetch NFT metadata for displaying images/name (for example, integrate with Metaplex JS SDK or Solana RPC calls to get metadata URI). 
- **Comments & UX:** Comment the Rust code to explain account layouts (especially the listing PDA structure). In the front-end code, add comments where you integrate with Solana (e.g., when sending a transaction). Ensure the UI has error handling (e.g., if a transaction fails or if user doesn’t have enough SOL). Format the output as two code sections: Anchor program and front-end.

This prompt is more complex, but it shows how to instruct the AI to handle a realistic scenario. Key points:

  • We explicitly reference Metaplex token metadata and typical marketplace behavior. This nudges the AI to use existing standards and best practices for NFTs on Solana, rather than something made-up. (This is an example of leveraging context: even if the AI isn’t perfectly aware of Metaplex, mentioning it will shape its output logic appropriately.)

  • We outlined the program’s instruction set and data (listing with price, etc.), which gives the AI a scaffold to implement.

  • We also outlined front-end features like displaying images and integrating wallet – this ensures the AI-generated UI isn’t bare-bones but actually does the important stuff (like showing NFT details).

  • The inclusion of comments and error handling again reinforces quality.

After getting an output from such a prompt, you would definitely need to review things: e.g., does the program properly use the token program to transfer NFTs? Are there security checks on who can call buy_nft? The prompt’s clarity should lead the AI to cover much of this, but as always you refine as needed. You might do this dApp in stages (first just listing, then buying logic, then UI) if the initial attempt misses something.