Skip to content

Solana program for the Feedana project - decentralized feedback collection platform with IPFS integration and comprehensive validation.

Notifications You must be signed in to change notification settings

0xsouravm/feedana-program

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Feedana Program

Solana Anchor Rust IPFS TypeScript

Feedana is a decentralized feedback collection platform built on the Solana blockchain using the Anchor framework. It enables creators to collect feedback in a trustless, transparent manner while leveraging IPFS for decentralized data storage.

πŸ“‹ Table of Contents

🌟 Features

  • Decentralized Feedback Boards: Create feedback boards with unique identifiers
  • IPFS Integration: Store feedback data on IPFS for decentralized, immutable storage
  • Platform Fees: Built-in fee structure to support platform sustainability
  • Secure Validation: Comprehensive input validation for board IDs and IPFS CIDs
  • Program Derived Addresses (PDAs): Deterministic addressing for feedback boards
  • Cross-Platform Compatibility: Works with any Solana-compatible wallet

πŸ—οΈ Architecture

Program ID

  • Devnet/Localnet: 3TwZoBQB7g8roimCHwUW7JTEHjGeZwvjcdQM5AeddqMY

Data Structure

pub struct FeedbackBoard {
    pub creator: Pubkey,     // 32 bytes - Board creator's public key
    pub ipfs_cid: String,    // 4 + up to 60 bytes - IPFS content identifier
    pub board_id: String,    // 4 + up to 28 bytes - Human-readable board identifier
}

Core Instructions

  1. create_feedback_board: Creates a new feedback board with platform fee payment
  2. submit_feedback: Updates existing board with new feedback data

πŸ’° Fee Structure

Action Fee Description
Create Board 10 lamports One-time fee for creating a feedback board
Submit Feedback 1 lamport Fee per feedback submission

Platform Wallet: 96fN4Eegj84PaUcyEJrxUztDjo7Q7MySJzV2skLfgchY

πŸ”’ Security Features

Input Validation

  • Board ID: 1-32 characters, alphanumeric and hyphens/underscores only
  • IPFS CID: 32-64 characters, must start with "Qm" (base58) or "b" (base32)
  • Duplicate Prevention: Uses PDAs to prevent duplicate boards per creator
  • Creator Restriction: Board creators cannot submit feedback on their own boards

Error Handling

The program includes comprehensive error codes:

pub enum FeedbackBoardError {
    InvalidIpfsCid,
    BoardIdTooLong,
    EmptyBoardId,
    EmptyIpfsCid,
    DuplicateFeedbackBoard,
    InsufficientFunds,
    InvalidIpfsCidLength,
    InvalidBoardIdChars,
    FeedbackBoardNotFound,
    UnauthorizedAccess,
    CreatorCannotSubmit,
}

Events

The program emits events for important state changes:

#[event]
pub struct FeedbackBoardCreated {
    pub creator: Pubkey,
    pub board_id: String,
    pub ipfs_cid: String,
}

#[event]
pub struct FeedbackSubmitted {
    pub board_id: String,
    pub new_ipfs_cid: String,
    pub feedback_giver: Pubkey,
}

πŸ§ͺ Testing

The test suite covers:

  • βœ… Successful board creation and feedback submission with event verification
  • βœ… Input validation (empty/invalid board IDs and IPFS CIDs)
  • βœ… Board ID length and character validation
  • βœ… Creator self-feedback prevention (CreatorCannotSubmit)
  • βœ… Duplicate board prevention
  • βœ… Insufficient funds handling
  • βœ… Platform fee verification
  • βœ… Multiple feedback submissions
  • βœ… Non-existent board handling
  • βœ… Event emission verification

Run the complete test suite:

yarn test
# or
npm run test

🌐 Frontend Integration

Frontend Repository: Feedana UI

The frontend provides a user-friendly interface for:

  • Creating and managing feedback boards
  • Submitting feedback with rich text editing
  • Viewing feedback history
  • Wallet integration for Solana payments

πŸ“ Project Structure

feedana-program/
β”œβ”€β”€ programs/
β”‚   └── feedana/
β”‚       β”œβ”€β”€ src/
β”‚       β”‚   β”œβ”€β”€ lib.rs              # Main program entry point
β”‚       β”‚   β”œβ”€β”€ types.rs            # Data structures
β”‚       β”‚   β”œβ”€β”€ errors.rs           # Custom error definitions
β”‚       β”‚   β”œβ”€β”€ events.rs           # Event definitions 
β”‚       β”‚   └── instructions/
β”‚       β”‚       β”œβ”€β”€ mod.rs
β”‚       β”‚       β”œβ”€β”€ create_board.rs # Board creation logic
β”‚       β”‚       └── submit_feedback.rs # Feedback submission logic
β”‚       β”œβ”€β”€ Cargo.toml
β”‚       └── Xargo.toml
β”œβ”€β”€ tests/
β”‚   └── feedana.ts                  # Comprehensive test suite
β”œβ”€β”€ migrations/
β”‚   └── deploy.ts                   # Deployment script
β”œβ”€β”€ Anchor.toml                     # Anchor configuration
β”œβ”€β”€ package.json                    # Node.js dependencies
└── tsconfig.json                   # TypeScript configuration

πŸ”— Related Links

πŸ“‹ API Reference

Instructions

create_feedback_board

Creates a new feedback board with the specified board ID and initial IPFS CID.

Parameters:

  • board_id: String (1-32 chars, alphanumeric + hyphens/underscores)
  • ipfs_cid: String (32-64 chars, valid IPFS CID format)

Accounts:

  • feedback_board: PDA account to be created
  • creator: Signer and payer
  • platform_wallet: Platform fee recipient
  • system_program: System program for account creation

Fee: 10 lamports

submit_feedback

Updates an existing feedback board with new IPFS CID containing updated feedback data.

Parameters:

  • new_ipfs_cid: String (32-64 chars, valid IPFS CID format)

Accounts:

  • feedback_board: Existing feedback board PDA
  • feedback_giver: Signer and fee payer
  • platform_wallet: Platform fee recipient
  • system_program: System program for fee transfer

Fee: 1 lamport

PDA Seeds

Feedback boards use the following seed structure:

["feedback_board", creator_pubkey, board_id]

This ensures:

  • Deterministic addressing
  • Creator can have multiple boards with different IDs
  • No collision between different creators

Events

The program emits the following events:

FeedbackBoardCreated

Emitted when a new feedback board is successfully created.

Fields:

  • creator: Pubkey - The public key of the board creator
  • board_id: String - The unique identifier of the board
  • ipfs_cid: String - The initial IPFS content identifier

FeedbackSubmitted

Emitted when feedback is successfully submitted to a board.

Fields:

  • board_id: String - The identifier of the feedback board
  • new_ipfs_cid: String - The updated IPFS content identifier
  • feedback_giver: Pubkey - The public key of the feedback submitter

These events can be consumed by frontend applications for real-time updates and analytics tracking.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m 'Add amazing feature'
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License.

⚠️ Disclaimer

This is educational/demonstration software. Use at your own risk. Always audit smart contracts before deploying to mainnet with significant funds.

About

Solana program for the Feedana project - decentralized feedback collection platform with IPFS integration and comprehensive validation.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published