Skip to content

Latest commit

Β 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 

Repository files navigation

Royalty-Splitter

🟑 Priority: Medium | Difficulty: Low–Medium | Estimated Effort: 1–2 days

The royalty distribution contract for the Afristore Marketplace β€” extracted from the monorepo into its own dedicated repository.

This Soroban smart contract implements:

  • initialize β€” Set up the contract with admin address and initial recipient splits
  • distribute_royalties β€” Distribute incoming royalty tokens proportionally to all recipients
  • update_royalty_split β€” Admin-only function to update the percentage allocations per recipient
  • get_split β€” Query the current split configuration

Invariants enforced by the contract:

  • All recipient shares must sum to exactly 100%
  • Only the admin can call update_royalty_split (enforced via require_auth)
  • Invalid splits (not summing to 100%) are rejected on initialization and update

πŸš€ Getting Started (once code is populated)

# Build the contract WASM
cargo build --target wasm32-unknown-unknown --release

# Run all tests
cargo test --features testutils

# Check formatting and linting
cargo fmt --check
cargo clippy -- -D warnings

# Optimize the WASM binary
stellar contract optimize --wasm target/wasm32-unknown-unknown/release/royalty_splitter.wasm

# Deploy to testnet
stellar contract deploy --wasm target/wasm32-unknown-unknown/release/royalty_splitter.optimized.wasm --network testnet

πŸ”§ Prerequisites

  • Rust (stable)
  • wasm32-unknown-unknown target: rustup target add wasm32-unknown-unknown
  • Stellar CLI: cargo install --locked stellar-cli

πŸ” Security

  • update_royalty_split requires admin authorization via require_auth β€” non-admin calls will panic.
  • Any split configuration where shares do not sum to 100% is rejected.

πŸ“‹ Source Location (Monorepo)

This repository is being extracted from afristore/contracts/royalty-splitter/ in the main monorepo.

Tracked in: ui-ux-issues.md β€” Issue 125


🀝 Contributing

  1. Fork this repository
  2. Create a feature branch: git checkout -b feat/your-feature
  3. Make your changes and ensure all CI checks pass:
    • cargo fmt --check β€” must exit 0
    • cargo clippy -- -D warnings β€” zero warnings
    • cargo test --features testutils β€” full royalty lifecycle tests must pass (initialize β†’ distribute β†’ update split β†’ distribute again)
    • Non-admin update_royalty_split calls must panic/fail with auth error
    • Invalid splits (not summing to 100%) must be rejected
    • cargo build --target wasm32-unknown-unknown --release β€” must produce a valid WASM
  4. Open a PR β€” all CI must pass before a PR is eligible for review and merge

πŸ“¦ Tech Stack

  • Rust + soroban-sdk v25.3.0
  • Stellar / Soroban smart contract platform

πŸ“„ License

MIT β€” see LICENSE

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors