Overview · Functions · Architecture · Deploy · Testing
| Feature | Status | Branch |
|---|---|---|
| Core marketplace contract | ✅ Done | main |
| Three license tiers (Lease/Premium/Exclusive) | ✅ Done | main |
| 90/10 revenue split with XLM token transfer | ✅ Done | main |
| Collaborator revenue split (basis points) | 🔄 In Progress | feat/collab-splits |
| Dispute resolution for exclusive purchases | 📋 Planned | — |
| Mainnet deployment | 📋 Planned | — |
The crate_marketplace contract is the source of truth for every beat sale on Crate. It handles payments, licensing, and revenue splits — without any intermediary.
No escrow service. No payment processor. No chargebacks. The contract enforces every rule at the protocol level.
"A producer selling a $20 beat on Ethereum loses $5+ in gas. On Crate, the contract takes $2. The producer keeps $18."
| Network | Address |
|---|---|
| Stellar Testnet | CA7DGEWWS3VH5J2I4I7FFEB5UHK2MJSYWDKDQKXQM7GDNLI2IRATDTLG |
| Stellar Mainnet | Coming soon |
| Function | Auth | Description |
|---|---|---|
__constructor(platform_fee, platform_address) |
— | Initialize with fee (basis points) and platform wallet |
upload_sample(uploader, title, ipfs_cid, lease_price, premium_price, exclusive_price, genre, bpm) |
uploader |
List a beat with all three tier prices |
purchase_license(buyer, sample_id, token_address, tier) |
buyer |
Buy a license — XLM transfers immediately, 90/10 split |
withdraw_earnings(producer, token_address) |
producer |
Pull accumulated balance to wallet |
delist_sample(uploader, sample_id) |
uploader |
Remove listing — fails if any license sold |
| Function | Returns | Description |
|---|---|---|
get_sample(sample_id) |
SampleData |
Full metadata + prices + sale count + exclusivity |
get_earnings(address) |
i128 |
Withdrawable balance in stroops |
get_stats() |
(u32, i128) |
Total samples listed + total XLM volume |
Producer calls upload_sample()
│
▼
┌───────────────────────────────────────────┐
│ crate_marketplace │
│ │
│ SampleData { │
│ id, uploader, title, ipfs_cid │
│ lease_price, premium_price │
│ exclusive_price, genre, bpm │
│ is_exclusive, total_sales │
│ } │
│ │
│ purchase_license(buyer, id, token, tier) │
│ ├─ 90% ──▶ producer earnings ledger │
│ └─ 10% ──▶ platform address (instant) │
│ │
│ withdraw_earnings(producer, token) │
│ └─ pull balance ──▶ producer wallet │
└───────────────────────────────────────────┘
Soroban / Stellar
pub struct SampleData {
pub id: u32,
pub uploader: Address,
pub title: String,
pub ipfs_cid: String, // IPFS content hash
pub lease_price: i128, // stroops
pub premium_price: i128,
pub exclusive_price: i128,
pub genre: String,
pub bpm: u32, // validated: 40–300
pub is_exclusive: bool, // true = sold exclusively, delisted
pub total_sales: u32,
}| Tier | Value | What the buyer gets |
|---|---|---|
0 — Lease |
lease_price |
Non-exclusive, limited commercial, 100k streams |
1 — Premium |
premium_price |
Commercial, unlimited streams, radio rights |
2 — Exclusive |
exclusive_price |
Full ownership transfer, beat delisted forever |
# Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add wasm32-unknown-unknown
# Stellar CLI
cargo install --locked stellar-cli# Build WASM
make build
# Run tests
make test
# Optimize WASM size (~40% smaller)
make optimize# Deploy contract to testnet
make deploy
# Initialize (one-time)
stellar contract invoke \
--id YOUR_CONTRACT_ID \
--source YOUR_ACCOUNT \
--network testnet \
-- __constructor \
--platform_fee 1000 \
--platform_address YOUR_PLATFORM_ADDRESSTests live in contracts/crate_marketplace/src/test.rs and cover:
upload_sample— metadata stored, counter incrementedpurchase_license— XLM split verification (90/10 arithmetic)withdraw_earnings— pull pattern, double-withdraw preventionexclusive purchase— beat auto-delisted after tier-2 saleget_stats— volume accumulation
# Fork → clone → branch
git checkout -b feat/your-feature
# Make changes, run tests
cargo test
# Open a PR| Repo | Description |
|---|---|
| crate-frontend | React 18 + TypeScript web app |
| crate-backend | Node.js API, IPFS proxy, analytics |
| crate-mobile | React Native mobile app |
MIT — see LICENSE