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 1: Staking Dashboard dApp

PreviousExamples for Common dApp ScenariosNextExample 2: NFT Marketplace / Platform

Last updated 1 month ago

CtrlK

Scenario: A dApp where users can stake a custom SPL token and earn rewards, with a dashboard showing staked balances and accrued rewards.

Prompt Example:

markdownKopierenBearbeitenYou are an expert Solana developer using Anchor and React. 

**Task:** Build a **token staking dApp** on Solana. 

**Requirements:**
- **Solana Program (Rust/Anchor):** Create an Anchor program that allows users to stake and unstake a specific SPL token. It should record each user's staked amount and calculate rewards over time (e.g., 5% of staked amount per epoch). Use a PDA to store staking account data for each user (seeded by user pubkey). Include instructions: `initialize_stake_account`, `stake_tokens(amount)`, and `unstake_tokens(amount)`. Validate that only the owner of a stake account can stake/unstake, and handle errors (e.g., unstaking more than staked, or if no stake account exists).
- **Front-End (React/TypeScript):** Provide a simple dashboard interface. Use Solana's wallet adapter (e.g. Phantom) for user to connect their wallet. Display the user's current staked balance and calculated rewards in real-time. Include forms or buttons to call the `stake_tokens` and `unstake_tokens` instructions (via solana web3.js or Anchor’s client). After staking or unstaking, update the displayed balances.
- **Additional:** Include inline code comments explaining key sections (especially in the on-chain program logic). Ensure the front-end handles transaction errors gracefully (e.g., show an alert if the transaction fails).

**Output Format:** Give the complete Anchor program code (with appropriate struct definitions, instructions, and error handling), and the React front-end code (perhaps a single-page app) in separate blocks. 

In this prompt, notice several things we did:

  • We specified the role and expertise of the AI (“expert Solana developer using Anchor and React”).

  • We clearly described the dApp’s functionality (“token staking” with rewards, etc.).

  • The requirements are broken down into the on-chain program and the front-end, each with details. This ensures the AI covers both parts of the dApp.

  • We explicitly mentioned Solana-specific concepts like Anchor, PDA, and using the wallet adapter, guiding the AI to the right tools.

  • We included expectations for error handling and comments, which improves the quality of the code output.

Such a prompt gives the AI a comprehensive blueprint. The output from Nyvo should be an Anchor program that defines a stake account (with fields for amount staked, owner, maybe a last updated timestamp for rewards) and functions to stake/unstake, plus a React app that connects to the wallet and calls those functions. Because we asked for inline comments, the AI is likely to annotate the code explaining, for example, how the PDA is derived or why a certain error check is done (e.g., “// Ensure the user cannot unstake more than they have staked”). This makes it easier to understand and trust the generated code.