Skip to content

N-45div/Craftpay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CraftPay

Programmable Creator Payments for X/Twitter

Ethereum Mainnet MNEE Token License: MIT

Live Demo · Architecture · Smart Contracts


The Problem

X/Twitter's native creator payouts are:

  • Opaque: No visibility into how payments are calculated
  • Slow: Weekly/monthly settlements with arbitrary thresholds
  • Restrictive: Only available to verified creators in select countries
  • Centralized: X controls everything—rates, eligibility, timing

The Solution

CraftPay is a trustless payment protocol that:

  1. Tracks X engagement in real-time via X API v2
  2. Calculates payouts using transparent, on-chain rates
  3. Enables instant settlement via shareable Payment Links
  4. Uses MNEE stablecoin (USD-pegged, 18 decimals) on Ethereum mainnet

No intermediaries. No custody. No waiting.


How It Works

sequenceDiagram
    participant Brand
    participant CraftPay
    participant X API
    participant Smart Contract
    participant Creator

    Brand->>CraftPay: Create Campaign
    Brand->>Smart Contract: Deposit MNEE to Escrow
    Creator->>CraftPay: Link Tweet URLs
    CraftPay->>X API: Fetch Engagement Metrics
    X API-->>CraftPay: Likes, Retweets, Replies, Quotes
    CraftPay->>CraftPay: Calculate MNEE Owed
    CraftPay->>Brand: Generate Payment QR Code
    Brand->>Smart Contract: Scan QR → Sign sponsorRelease()
    Smart Contract->>Creator: Transfer MNEE from Escrow
Loading

Key Features

Feature Description
Real-time Metrics Live X API v2 integration for likes, retweets, replies, quotes
Payment Links Shareable URLs for instant sponsor-to-creator payments
Escrow Deposits Brands lock MNEE in smart contract before campaigns
Direct MNEE Transfer One-click payment with preset amounts ($1, $5, $25, $100)
Transparent Rates Fixed per-engagement rates, fully auditable
On-chain Verification Every transaction on Etherscan

Payout Rates

Engagement Type MNEE per Action USD Equivalent
Like ❤️ 0.001 MNEE $0.001
Retweet 🔁 0.005 MNEE $0.005
Reply 💬 0.003 MNEE $0.003
Quote Tweet 📝 0.010 MNEE $0.010

Example: A tweet with 1,000 likes + 100 retweets = 1.50 MNEE ($1.50)


Smart Contracts

Deployed on Ethereum Mainnet:

Contract Address Etherscan
MNEE Token 0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF View
CreatorPayoutPool 0x59E386DD3C1A369e5189DC928D679Fa036845209 View

Contract Functions

// Brand deposits MNEE into campaign escrow
function depositForCampaign(bytes32 campaignId, uint256 amount, string metadata)

// Brand releases funds to creator via QR code (trustless)
function sponsorRelease(bytes32 campaignId, address creator, uint256 amount)

// Check campaign balance
function campaignBalance(bytes32 campaignId) view returns (uint256)

Tech Stack

Layer Technology
Smart Contracts Solidity 0.8.20, Foundry, OpenZeppelin
Backend Node.js, Express, TypeScript, Prisma, PostgreSQL
Frontend Next.js 14, React, TailwindCSS, shadcn/ui
Blockchain Ethereum Mainnet, wagmi, viem
APIs X API v2, WalletConnect

Getting Started

Prerequisites

  • Node.js 18+
  • PostgreSQL (or Neon serverless)
  • X API Bearer Token (developer.x.com)
  • Ethereum wallet with ETH for gas

Quick Start

# Clone
git clone https://github.com/N-45div/Craftpay.git
cd Craftpay

# Backend
cd backend
npm install
cp .env.example .env
# Edit .env: DATABASE_URL, X_BEARER_TOKEN
npx prisma db push
npm run dev

# Frontend (new terminal)
cd frontend
npm install
npm run dev

Open http://localhost:3000

Environment Variables

Backend (.env):

DATABASE_URL=postgresql://...
X_BEARER_TOKEN=AAAA...
MAINNET_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/...
PAYOUT_POOL_ADDRESS=0x59E386DD3C1A369e5189DC928D679Fa036845209
MNEE_TOKEN_ADDRESS=0x8ccedbAe4916b79da7F3F612EfB2EB93A2bFD6cF

Frontend (.env.local):

NEXT_PUBLIC_API_URL=http://localhost:8080
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=...
NEXT_PUBLIC_PAYOUT_POOL_ADDRESS=0x59E386DD3C1A369e5189DC928D679Fa036845209

Demo Flow

1. Create Campaign

  • Go to X Campaigns → Click Create Campaign
  • Enter brand/sponsor name

2. Link Tweets

  • Click Add Tweet → Paste any X/Twitter URL
  • Example: https://x.com/elonmusk/status/1234567890

3. Fetch Metrics

  • Click Refresh Metrics or Load Demo Data for testing
  • Real-time engagement data from X API

4. Get Payment Link

  • Click Get Payment Link → Copies shareable URL
  • Share with sponsor via Twitter DM, email, etc.

5. Sponsor Pays Creator

  • Sponsor opens payment link
  • Connects wallet → Picks amount ($1, $5, $25, $100 or custom)
  • Clicks Pay → Signs transaction
  • Creator receives MNEE instantly! 🎉

6. Verify On-Chain

  • Click View on Etherscan
  • Transaction is publicly verifiable

Why CraftPay?

vs X Creator Payouts CraftPay
Opaque rates Transparent, on-chain rates
Weekly/monthly settlement Instant
Country restrictions Global
Centralized control Trustless smart contracts
Arbitrary eligibility Anyone can participate

Project Structure

craftpay/
├── contracts/           # Foundry smart contracts
│   ├── contracts/       # Solidity source
│   ├── script/          # Deployment scripts
│   └── test/            # Contract tests
├── backend/             # Express API server
│   ├── src/routes/      # API endpoints
│   └── prisma/          # Database schema
├── frontend/            # Next.js 14 app
│   ├── src/app/         # App router pages
│   └── src/components/  # React components
└── ARCHITECTURE.md      # System design docs

License

MIT License - see LICENSE for details.


MNEE Hackathon Submission

Built for: MNEE Hackathon - Programmable Money for Agents, Commerce, and Automated Finance

Category: Creator Payments / Social Commerce

Key Innovations:

  • First X engagement → crypto payment protocol
  • Shareable Payment Links for frictionless sponsor payments
  • Direct MNEE transfers with preset amounts ($1, $5, $25, $100)
  • Real MNEE (18 decimals) on Ethereum mainnet (not testnet)

CraftPay - Turn X engagement into MNEE

Made with ❤️ for the MNEE Hackathon

About

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors