Skip to content

This is a decentralized tipping platform built on the Stacks blockchain. It enables users to send and receive tips seamlessly, with advanced features like user statistics, rewards, identity verification, and platform fee handling. Designed for efficiency and transparency, this smart contract promotes decentralized financial interaction.

License

Notifications You must be signed in to change notification settings

Arowolokehinde/STX-TIP

Repository files navigation

Tip Stacks

TiP Stacks is a decentralized tipping platform built on the Stacks blockchain built with AI. It enables users to send and receive tips seamlessly, with advanced features like user statistics, rewards, identity verification, and platform fee handling. Designed for efficiency and transparency, this smart contract promotes decentralized financial interaction.


Deployed smart contract url

https://explorer.hiro.so/txid/0x3cd2275570b99fc8df9168c917ae65c05f44494ef05f8c8ab438e150923badf8?chain=testnet ST3P8GST1CH1QTD2W8VQ9BT60EPBQFWDN9DRGBR64.STX-TIPPPS

Features

Key Features

  1. Decentralized Tipping: Enables users to tip others directly on the Stacks blockchain.
  2. Platform Fees: A percentage fee is deducted from each tip for platform sustainability.
  3. Reward System: Users earn reward points for tipping amounts exceeding a threshold.
  4. User Statistics:
    • Total tips sent and received.
    • Accumulated reward points.
  5. Identity Management: Links user addresses to usernames and verification status.
  6. Transaction History: Maintains a detailed log of tipping activities.
  7. Error Handling: Comprehensive error codes to handle edge cases and ensure contract integrity.

Firstly, you have to connect wallet, then you would join community and then you can view your dashboard

Screenshot 2024-12-14 at 9 46 29 PM Screenshot 2024-12-14 at 9 46 47 PM

Smart Contract Components

Constants

  • CONTRACT_OWNER: The owner's principal address.
  • PLATFORM_FEE_PERCENTAGE: Fee percentage (default: 5%).
  • MAX_TIP_AMOUNT: Maximum allowable tip amount (default: 1,000 STX).
  • REWARD_THRESHOLD: Minimum tip amount to qualify for rewards (default: 1 STX).
  • REWARD_RATE: Points earned per qualifying tip (default: 10 points).

Data Structures

  • user-tip-stats: Tracks individual user statistics.
    { total-tips-sent: uint, total-tips-received: uint, reward-points: uint }
  • tip-history: Logs transactions.
    { sender: principal, recipient: principal, timestamp: uint, amount: uint, fee: uint, token-type: string }
  • user-identity: Stores user profiles.
    { username: string, verified: bool }

Key Functions

Public Functions

  1. tip:

    • Transfers a tip to a recipient, deducting a platform fee.
    • Updates user stats and logs the transaction.
    • Example:
      (tip 'SP123456789' u1000 "STX")
  2. set-user-identity:

    • Registers or updates a user's username.
    • Example:
      (set-user-identity "Alice")
  3. update-user-reward-points:

    • Updates reward points for a user manually.
    • Example:
      (update-user-reward-points 'SP123456789' u20)
  4. Read-Only Functions:

    • get-user-tip-stats: Retrieve a user's tipping statistics.
    • get-user-identity: Fetch a user's identity information.
    • get-transaction-logs: Access logs of a specific transaction.
Screenshot 2024-12-14 at 9 50 48 PM

Private Functions

  • process-tip-transfer: Handles the actual fund transfer and fee deduction.
  • calculate-platform-fee: Computes the platform fee from the tip amount.
  • update-sender-stats & update-recipient-stats: Updates user statistics after a successful tip.
  • update-reward-points: Grants reward points to eligible users.

Installation & Deployment

  1. Environment Setup: Ensure you have:

    • Clarity development tools installed.
    • A connected Stacks wallet.
  2. Deploy: Deploy the contract using the Stacks CLI or your preferred IDE:

    stacks deploy ./tip-stacks-enhanced.clar
  3. Configuration:

    • Update the constants to match your platform's settings.
    • Ensure the CONTRACT_OWNER address is correct.

Usage Guidelines

  • For Users:

    • Use the tip function to send tips.
    • Query get-user-tip-stats for your statistics.
    • Link your identity using set-user-identity.
  • For Platform Owners:

    • Monitor platform fees and reward points.
    • Handle user verification through user-identity.

Error Handling

Common Errors

  • ERR_INSUFFICIENT_FUNDS (u1): Tip amount exceeds sender's balance.
  • ERR_INVALID_AMOUNT (u2): Tip amount is invalid (e.g., zero or exceeds maximum).
  • ERR_TRANSFER_FAILED (u3): Fund transfer failed due to network or balance issues.
  • ERR_REWARD_UPDATE_FAILED (u4): Reward points update failed.

Screenshot 2024-12-14 at 9 46 47 PM

Future Enhancements

  1. Multi-token Support: Extend tipping functionality to include other tokens.
  2. Advanced Identity Verification: Integrate with decentralized identity solutions.
  3. Dynamic Reward Rates: Implement tiered reward mechanisms based on user activity.

About

This is a decentralized tipping platform built on the Stacks blockchain. It enables users to send and receive tips seamlessly, with advanced features like user statistics, rewards, identity verification, and platform fee handling. Designed for efficiency and transparency, this smart contract promotes decentralized financial interaction.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published