StreamFund is a decentralized continuous funding platform with vesting capabilities implemented as a smart contract on the Stacks blockchain. The platform enables creators to receive ongoing crowdfunding with gradual fund release through vesting mechanisms.
- Overview
- Architecture
- Key Features
- Smart Contracts
- StreamFund Contract
- Governance Token Contract
- Usage
- For Creators
- For Contributors
- For Governance Token Holders
- Technical Details
- Security Considerations
- Contributing
- License
StreamFund provides a flexible funding model where creators can receive continuous financial support without fixed goals. Funds are released gradually over a vesting period, ensuring sustainable project development. Additionally, the platform includes a governance system that enables token holders to participate in decision-making processes.
The platform consists of two main components:
- StreamFund Contract - Manages campaign creation, contributions, and vesting schedules
- Governance Token Contract - Handles governance mechanisms, including proposal creation and voting
- Continuous Funding: No fixed funding goals, allowing campaigns to receive funding indefinitely
- Gradual Fund Release: Vesting mechanism that releases funds to creators over time
- Minimum Contribution: Configurable minimum contribution amount per campaign
- Campaign Deactivation: Ability to halt new contributions while preserving the vesting schedule
- Transparent Fund Tracking: Public functions to monitor campaign metrics
- Token-Based Governance: Decision-making through proposal and voting mechanisms
- Role-Based Access Control: Admin and minter roles with specific permissions
- Transfer Limits: Daily transfer limits to prevent token dumping
- Secure Token Management: Functions for minting and burning tokens
(define-constant CONTRACT-OWNER tx-sender)
(define-constant ERR-NOT-AUTHORIZED (err u500))
(define-constant ERR-CAMPAIGN-NOT-FOUND (err u501))
(define-constant ERR-CAMPAIGN-INACTIVE (err u502))
(define-constant ERR-INSUFFICIENT-AMOUNT (err u503))
(define-constant ERR-NOTHING-TO-CLAIM (err u504))
Campaigns: Stores campaign attributesContributions: Tracks individual contributionscampaign-counter: Manages unique campaign IDs
create-campaign: Create a new funding campaigncontribute: Contribute to an active campaignclaim-vested: Claim vested funds as a campaign creatordeactivate-campaign: Deactivate a campaignget-campaign: Get details of a specific campaign (read-only)get-contribution: Get details of a contributor's contribution (read-only)
(define-constant CONTRACT-OWNER tx-sender)
(define-constant ERR-UNAUTHORIZED (err u100))
(define-constant ERR-INSUFFICIENT-BALANCE (err u101))
(define-constant ERR-INVALID-PROPOSAL (err u102))
(define-constant ERR-ALREADY-VOTED (err u103))
(define-constant ERR-TRANSFER-LIMIT-EXCEEDED (err u104))
(define-constant ERR-INVALID-TRANSFER-AMOUNT (err u105))
(define-constant DAILY-TRANSFER-LIMIT u10000)
(define-constant BLOCKS-PER-DAY u144)
user-roles: Tracks admin and minter rolesproposals: Stores proposal informationproposal-votes: Tracks votes on proposalstransfer-limits: Manages user transfer limitslast-proposal-id: Tracks the latest proposal ID
mint-tokens: Mint new governance tokensburn-tokens: Burn governance tokensset-user-role: Assign or revoke rolescreate-proposal: Create a new governance proposalvote-on-proposal: Vote on an existing proposalsafe-transfer: Transfer tokens with additional checksset-user-transfer-limit: Customize transfer limits for users
-
Create a Campaign
(contract-call? .streamfund create-campaign u100 u10000)This creates a campaign with a minimum contribution of 100 STX and a vesting duration of 10,000 blocks.
-
Claim Vested Funds
(contract-call? .streamfund claim-vested u1)This claims the vested funds from campaign #1.
-
Deactivate a Campaign
(contract-call? .streamfund deactivate-campaign u1)This deactivates campaign #1, preventing new contributions.
-
Contribute to a Campaign
(contract-call? .streamfund contribute u1 u500)This contributes 500 STX to campaign #1.
-
Check Contribution
(contract-call? .streamfund get-contribution u1 tx-sender)This returns the contribution details for the current user to campaign #1.
-
Create a Proposal
(contract-call? .governance create-proposal "Increase Daily Transfer Limit" "Increase the daily transfer limit from 10,000 to 15,000 tokens") -
Vote on a Proposal
(contract-call? .governance vote-on-proposal u1 true)This casts a "for" vote on proposal #1.
-
Transfer Tokens
(contract-call? .governance safe-transfer u1000 tx-sender 'STCREAMDAFASDFSADF)This safely transfers 1,000 tokens to another account.
The vesting mechanism in StreamFund operates based on block height. The amount vested is calculated as:
vested-amount = (total-raised * elapsed-blocks) / vesting-duration
To prevent market manipulation, the governance token contract implements daily transfer limits calculated on a per-block basis:
blocks-per-day = 144 (assuming ~10 minute block times)
The governance contract implements role-based access control with two key roles:
- Admin: Can mint tokens and manage user roles
- Minter: Can mint tokens
- Authorization Checks: All sensitive functions include proper authorization checks
- Balance Validation: Operations that involve tokens validate balances before execution
- Transfer Limits: Governance token transfers are limited to prevent market manipulation
- Immutable Constants: Critical values are defined as constants to prevent unauthorized changes
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.