Rust + Soroban starter repository for a Stellar-based tipping application.
The tipjar smart contract lets supporters tip creators with a Stellar token, tracks creator totals in contract storage, emits on-chain events, and supports creator withdrawals from escrowed balances.
contracts/
tipjar/
src/
lib.rs
Cargo.toml
tests/
scripts/
README.md
CONTRIBUTING.md
init(token): one-time token configuration.tip(sender, creator, amount): transfers tokens from sender into contract escrow for creator and updates storage totals.get_total_tips(creator): returns total historical tips for creator.withdraw(creator): allows creator to withdraw escrowed tips.
The contract stores:
- token contract address (
DataKey::Token) - creator withdrawable balance (
DataKey::CreatorBalance) - creator total historical tips (
DataKey::CreatorTotal)
("tip", creator)with data(sender, amount)("withdraw", creator)with dataamount
- Rust toolchain
- Stellar CLI (
stellar) - Soroban target support for WASM:
rustup target add wasm32v1-nonecargo build -p tipjar --target wasm32v1-none --releasecargo test -p tipjarUnit tests use Soroban's test framework and cover:
- tipping flow
- total and withdrawable balance tracking
- invalid tip amount rejection
Use the helper script:
bash scripts/deploy.shOr run commands manually with stellar contract deploy and stellar contract invoke.
See CONTRIBUTING.md for:
- branching strategy
- coding standards
- test requirements
- pull request checklist
MIT