Skip to content

Repository files navigation

danfo-contracts

CI License: MIT Docs Soroban SDK

Soroban smart contracts for Danfo — a community-owned transit knowledge protocol for Lagos on Stellar.

📖 Documentation · 🌊 Contributing via Drips Wave · 🗺️ Roadmap


Lagos runs on informal danfo minibuses with no official map or fare data. Danfo lets riders and drivers maintain that data themselves, with real economic weight behind every edit:

  1. Stake — submitting a correction locks a small stake (danfo-registry.submit).
  2. Attest — peers approve or reject it during a challenge window (attest).
  3. Settle — after the window, anyone can finalize: accepted corrections refund the stake and become part of the knowledge base; rejected spam is slashed into the reward pool.
  4. Earn — accepted corrections claim a payout from the sponsor-funded danfo-rewards pool (claim), in XLM or NGNC (Stellar's naira stablecoin — redeemable to a Nigerian bank account via SEP-24).

So spam funds the people doing the real work. That loop is the whole design — stake economics does the arithmetic.

Contracts

Contract Responsibility
contracts/registry Correction lifecycle: staked submit → attest → finalize (refund/slash), plus reads and per-address reputation — API reference
contracts/rewards Sponsor-funded pool paying a fixed reward per accepted correction; pull-based, idempotent claims — API reference

danfo-rewards verifies acceptance by a cross-contract read of danfo-registry.get(id) — it never trusts the caller.

Build & test

rustup target add wasm32-unknown-unknown

# registry wasm must build first: rewards imports its interface
cargo build -p danfo-registry --release --target wasm32-unknown-unknown
cargo test --workspace
cargo build -p danfo-rewards --release --target wasm32-unknown-unknown

34 tests — 23 in the registry, 11 in the rewards pool, including a cross-contract integration test that drives one correction from submission to payout. Full setup in the quickstart.

Known pin: ed25519-dalek is held at 2.x in Cargo.lock; soroban-env-host 22.x does not compile against dalek 3.0.

Deploy (testnet)

./scripts/deploy.sh

Deploys both contracts in dependency order, initializes them, points the registry's slash_recipient at the rewards pool, and prints the contract ids to paste into the application layer's environment. Tunables and verification commands: deploying to testnet.

Launch defaults: 10 XLM stake, 24 h challenge window, 2 minimum attestations, 5 XLM reward — all admin-tunable via set_config / set_reward, and all readable on-chain via get_config.

Contributing

Newcomers start with issues labelled trivial; the open design questions are labelled needs-design and want a discussion before code.

Related

The application layer — the multilingual AI transit agent, the corrections feed, and the indexer — lives in a separate repository, danfo-app. This repository is the on-chain half and stands alone: everything here builds, tests, and deploys without it.

Status

Unaudited testnet software. Do not use with mainnet funds. The threat model sets out what these contracts defend against, what they do not, and the open problems. Vulnerability disclosure: SECURITY.md.

License

MIT

About

Soroban contracts for Danfo - staked community transit corrections and rewards on Stellar

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages