A crowdfunding smart contract built on the Stellar network using Soroban.
Stellar Raise lets anyone create a crowdfunding campaign on-chain. Contributors pledge tokens toward a goal before a deadline. If the goal is met, the creator withdraws the funds. If not, contributors are refunded automatically.
| Feature | Description |
|---|---|
| Initialize | Create a campaign with a goal, deadline, and token |
| Contribute | Pledge tokens before the deadline |
| Withdraw | Creator claims funds after a successful campaign |
| Refund | Contributors reclaim tokens if the goal is missed |
stellar-raise-contracts/
├── .github/workflows/rust_ci.yml # CI pipeline
├── contracts/crowdfund/
│ ├── src/
│ │ ├── lib.rs # Smart contract logic
│ │ └── test.rs # Unit tests
│ └── Cargo.toml # Contract dependencies
├── Cargo.toml # Workspace config
├── CONTRIBUTING.md
├── README.md
└── LICENSE
-
Rust (stable)
-
The
wasm32-unknown-unknowntarget:rustup target add wasm32-unknown-unknown
-
Stellar CLI (optional, for deployment)
# Clone the repo
git clone https://github.com/<your-org>/stellar-raise-contracts.git
cd stellar-raise-contracts
# Build the contract
cargo build --release --target wasm32-unknown-unknown
# Run tests
cargo test --workspace// Create a new campaign
fn initialize(env, creator, token, goal, deadline);
// Pledge tokens to the campaign
fn contribute(env, contributor, amount);
// Creator withdraws after successful campaign
fn withdraw(env);
// Refund all contributors if goal not met
fn refund(env);
// View functions
fn total_raised(env) -> i128;
fn goal(env) -> i128;
fn deadline(env) -> u64;
fn contribution(env, contributor) -> i128;Once deployed, the contract can be upgraded to a new WASM implementation without changing its address or losing stored data. This allows the project to ship fixes and improvements without redeploying.
-
Build the new WASM binary:
cargo build --release --target wasm32-unknown-unknown
-
Upload the new WASM to the network:
stellar contract install \ --wasm target/wasm32-unknown-unknown/release/crowdfund.wasm \ --network testnet \ --source <YOUR_SECRET_KEY>
This returns the WASM hash (SHA-256).
-
Invoke the upgrade function:
stellar contract invoke \ --id <CONTRACT_ADDRESS> \ --fn upgrade \ --arg <WASM_HASH> \ --network testnet \ --source <YOUR_SECRET_KEY>
- Only the admin (set to the campaign creator at initialization) can call the upgrade function.
- The upgrade is irreversible — ensure the new WASM is thoroughly tested before upgrading.
- All contract storage and state persist across upgrades.
- The contract address remains the same after an upgrade.
- Recommendation: Have at least two reviewers approve upgrade PRs before merging to production.
# Build the optimized WASM
cargo build --release --target wasm32-unknown-unknown
# Deploy using Stellar CLI
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/crowdfund.wasm \
--network testnet \
--source <YOUR_SECRET_KEY>See CHANGELOG.md for a full history of notable changes.
Please review our Security Policy for responsible disclosure guidelines.
See CONTRIBUTING.md for guidelines.
This project is licensed under the MIT License — see the LICENSE file for details.