Soroban smart contracts powering the Creditedapp decentralized crowdfunding platform on Stellar.
This repository contains two Soroban smart contracts that power Creditedapp:
- Crowdfund — handles campaign creation, contributions, withdrawals, and refunds
- Registry — maintains a discoverable on-chain list of all deployed campaigns
Each campaign is its own deployed contract instance. The registry acts as a directory so frontends and indexers can find all campaigns without relying on off-chain databases.
- A creator deploys and initializes a campaign with a goal, deadline, token, and minimum contribution
- Contributors pledge tokens before the deadline
- Goal met → creator calls
withdraw()to claim funds (minus optional platform fee) - Goal missed → each contributor calls
refund_single()to reclaim their own tokens
The pull-based refund model means no single transaction needs to refund everyone — it scales to any number of contributors.
creditedapp-contracts/
├── crowdfund/ # Core crowdfunding contract
│ ├── src/
│ │ ├── lib.rs # Entry points & business logic
│ │ ├── types.rs # Data structures & events
│ │ ├── storage.rs # Storage key constants
│ │ ├── errors.rs # Error codes
│ │ └── validation.rs # Input validation helpers
│ ├── tests/ # Integration tests
│ └── Cargo.toml
├── registry/ # Campaign registry contract
│ ├── src/
│ │ └── lib.rs # register() + list() logic
│ └── Cargo.toml
├── benchmarks/ # Gas benchmarks
├── scripts/ # Deploy & ops scripts
├── terraform/ # Cloud infrastructure (AWS)
├── Cargo.toml # Rust workspace
└── Cargo.lock # Pinned dependencies
| Function | Description |
|---|---|
initialize(...) |
Create and configure a campaign |
contribute(contributor, amount) |
Pledge tokens before deadline |
withdraw() |
Creator claims funds after successful campaign |
refund_single(contributor) |
Contributor reclaims tokens if goal not met |
update_metadata(title, description, links) |
Update campaign info while active |
get_stats() |
Returns raised amount, progress %, contributor count |
goal() / deadline() / title() |
Read campaign parameters |
| Function | Description |
|---|---|
register(campaign_id) |
Add a campaign address to the directory |
list(offset, limit) |
Paginated list of all registered campaigns |
| Tool | Version | Install |
|---|---|---|
| Rust | 1.70+ | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh |
| wasm32 target | — | rustup target add wasm32-unknown-unknown |
| Stellar CLI | 21.0+ | docs.stellar.org |
git clone https://github.com/smiletech092-code/creditedapp-contracts.git
cd creditedapp-contractscargo build --release --target wasm32-unknown-unknownOutput: target/wasm32-unknown-unknown/release/*.wasm
cargo test --workspaceDEADLINE=$(date -d "+30 days" +%s)
./scripts/deploy.sh \
<CREATOR_ADDRESS> \
<TOKEN_ADDRESS> \
1000 \
$DEADLINE \
10 \
"My Campaign" \
"A great cause"The script prints the Contract ID and Registry ID — add these to your frontend .env.local.
make build # Compile contracts to WASM
make test # Run all tests
make lint # Run cargo clippy
make format # Run cargo fmt
make clean # Remove build artifacts
make deploy-testnet # Deploy to Stellar testnet| Script | Purpose |
|---|---|
deploy.sh |
Deploy & initialize contracts |
verify-contract.sh |
Verify on-chain deployment |
monitor-gas.sh |
Track gas usage |
monitor-events.sh |
Index contract events |
backup.sh |
Snapshot contract state |
rotate-secrets.sh |
Rotate deployment secrets |
switch-env.sh |
Switch between environments |
An optional PlatformConfig can be passed at initialization:
fee = total_raised × fee_bps / 10_000
creator_payout = total_raised - fee
Example: fee_bps = 250 → 2.5% platform fee.
Cargo.lock is committed intentionally. Smart contract WASM must be byte-for-byte reproducible so on-chain hashes can be independently verified. Floating dependencies break this guarantee.
- creditedapp-frontend — Next.js web app
Stellar provides 5-second finality and near-zero transaction fees, making it ideal for crowdfunding at scale. Soroban is Stellar's smart contract platform.
MIT © smiletech092-code