Skip to content

The Creator Tip Jar is a decentralized tipping platform smart contract built on the Stacks blockchain using Clarity. It enables direct peer-to-peer financial support between content creators and their supporters, eliminating intermediaries while maintaining transparent fee structures and secure fund management.

Notifications You must be signed in to change notification settings

doyin-b/Creator-Tip-Jar-Smart-Contract

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 

Repository files navigation

Creator Tip Jar Smart Contract

A decentralized tipping platform built on the Stacks blockchain that enables supporters to send tips directly to content creators with transparent fee structures and secure fund management.

Overview

The Creator Tip Jar contract provides a trustless infrastructure for tipping creators. Creators register their profiles, receive tips from supporters, and withdraw their earnings at any time. The platform charges a small fee (default 2.5%) to sustain operations.

Features

For Creators

  • Profile Management: Register with a username and bio, update profile information
  • Status Control: Toggle active/inactive status to control tip acceptance
  • Balance Tracking: Real-time balance tracking with complete transaction history
  • Flexible Withdrawals: Withdraw specific amounts or entire balance
  • Statistics: Track total tips received and number of supporters

For Supporters

  • Easy Tipping: Send tips with optional personalized messages (up to 280 characters)
  • Transparent Fees: Platform fee automatically calculated and displayed
  • Tip History: All tips are recorded on-chain with timestamps
  • Minimum Threshold: Minimum tip of 0.00001 STX ensures meaningful transactions

For Platform Admin

  • Fee Management: Adjust platform fee (0-10% maximum)
  • Revenue Collection: Withdraw accumulated platform fees
  • Platform Analytics: View total tips processed and platform statistics

Contract Functions

Public Functions

Creator Operations

(register-creator (username (string-ascii 50)) (bio (string-utf8 200)))

Register as a creator with username and bio.

(update-profile (bio (string-utf8 200)))

Update creator bio information.

(toggle-active-status)

Enable or disable tip acceptance.

(withdraw (amount uint))

Withdraw specified amount from creator balance.

(withdraw-all)

Withdraw entire creator balance.

Tipping Operations

(send-tip (creator principal) (amount uint) (message (optional (string-utf8 280))))

Send a tip to a creator with optional message.

Admin Operations

(set-platform-fee (new-fee-bps uint))

Update platform fee (admin only). Fee in basis points (250 = 2.5%).

(withdraw-platform-fees (amount uint))

Withdraw platform fees (admin only).

Read-Only Functions

(get-creator-info (creator principal))

Retrieve creator profile and statistics.

(get-creator-balance (creator principal))

Get current balance for a creator.

(get-tip (tip-id uint))

Retrieve details of a specific tip transaction.

(calculate-fee (amount uint))

Calculate platform fee for a given tip amount.

(calculate-net-amount (amount uint))

Calculate net amount creator receives after fees.

(is-creator (address principal))

Check if an address is a registered creator.

(get-platform-fee)

Get current platform fee percentage.

(get-platform-balance)

Get accumulated platform fees.

(get-total-tips-processed)

Get total value of all tips processed.

Error Codes

Code Constant Description
u100 err-owner-only Only contract owner can perform this action
u101 err-not-creator Address is not a registered creator
u102 err-invalid-amount Invalid tip amount (too low or zero)
u103 err-creator-exists Creator already registered
u104 err-creator-not-found Creator does not exist
u105 err-insufficient-balance Insufficient balance for withdrawal
u106 err-withdrawal-failed Withdrawal transaction failed
u107 err-invalid-fee Invalid fee percentage (exceeds 10%)
u108 err-creator-inactive Creator has disabled tip acceptance

Usage Examples

Registering as a Creator

(contract-call? .creator-tip-jar register-creator "alice-creates" u"Digital artist creating NFT collections")

Sending a Tip

(contract-call? .creator-tip-jar send-tip 'ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM u1000000 (some u"Love your work!"))

Withdrawing Earnings

(contract-call? .creator-tip-jar withdraw u5000000)

Fee Structure

  • Default Platform Fee: 2.5% (250 basis points)
  • Maximum Platform Fee: 10% (1000 basis points)
  • Minimum Tip Amount: 0.00001 STX (10,000 micro-STX)

The platform fee is deducted from each tip and accumulated in the platform balance for operational costs.

Security Considerations

  • All STX transfers are handled through secure contract mechanisms
  • Balance checks prevent overspending
  • Input validation on all user-provided data
  • Creator verification before operations
  • Admin functions restricted to contract owner
  • Safe arithmetic operations prevent overflows

Data Storage

The contract maintains:

  • Creator profiles: Username, bio, statistics, and status
  • Balance ledger: Individual creator balances
  • Tip records: Complete history with sender, recipient, amount, message, and timestamp
  • Platform metrics: Total tips processed and accumulated fees

Deployment

Deploy the contract to Stacks blockchain using Clarinet or Stacks CLI. The deployer becomes the contract owner with admin privileges.

About

The Creator Tip Jar is a decentralized tipping platform smart contract built on the Stacks blockchain using Clarity. It enables direct peer-to-peer financial support between content creators and their supporters, eliminating intermediaries while maintaining transparent fee structures and secure fund management.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors