|
| 1 | +# ADR-0001: Use Soroban (Rust) for Smart Contract Development |
| 2 | + |
| 3 | +**Status:** Accepted |
| 4 | +**Date:** 2024-01-15 |
| 5 | +**Authors:** [@rinafcode] |
| 6 | +**Reviewers:** [@rinafcode] |
| 7 | +**Tags:** contract, infrastructure |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## Context |
| 12 | + |
| 13 | +TeachLink requires a smart contract platform to manage tokenized learning rewards, proof-of-participation records, and educator incentive payouts. The contract must be auditable, deterministic, and deployable on a network with low transaction fees suitable for micro-reward use cases. |
| 14 | + |
| 15 | +Several smart contract platforms were available at the time of this decision. The choice of platform determines the programming language, toolchain, deployment target, and long-term maintenance burden. |
| 16 | + |
| 17 | +Key constraints: |
| 18 | + |
| 19 | +- Micro-transactions (reward payouts as small as fractions of a token) require negligible fees |
| 20 | +- The team has existing experience with Rust systems programming |
| 21 | +- The contract surface area is large (bridge, escrow, rewards, reputation, assessment modules), so type safety and compile-time correctness guarantees are important |
| 22 | +- Long-term auditability matters; the contract code must be readable and verifiable by external reviewers |
| 23 | + |
| 24 | +## Decision |
| 25 | + |
| 26 | +We will write TeachLink's smart contracts in Rust targeting the Soroban platform on the Stellar network. All contract modules (bridge, escrow, tokenization, rewards, reputation, assessment, emergency, audit, analytics, reporting, backup) will be compiled to `wasm32-unknown-unknown` and deployed as a single Soroban contract. |
| 27 | + |
| 28 | +## Alternatives Considered |
| 29 | + |
| 30 | +| Alternative | Reason Rejected | |
| 31 | +|-------------|-----------------| |
| 32 | +| Solidity on EVM (Ethereum / Polygon) | Gas fees unsuitable for micro-reward transactions; EVM bytecode harder to audit than Rust source; team preference for Rust type system | |
| 33 | +| Move on Aptos / Sui | Ecosystem too early at decision time; limited tooling and auditor familiarity; cross-chain bridge support was less mature | |
| 34 | +| CosmWasm (Rust on Cosmos) | Viable technically, but Stellar's Horizon API and SEP standards provide better fiat on/off-ramp integrations needed for educator payouts | |
| 35 | +| Ink! on Substrate | Strong Rust support, but Polkadot parachain deployment complexity was disproportionate to the project's scale | |
| 36 | + |
| 37 | +## Consequences |
| 38 | + |
| 39 | +### Positive |
| 40 | + |
| 41 | +- Rust's type system eliminates entire classes of contract bugs at compile time |
| 42 | +- `cargo test` and `cargo clippy` integrate naturally into CI, giving immediate feedback on contract correctness |
| 43 | +- Soroban's WASM execution environment is deterministic and sandboxed |
| 44 | +- Stellar's low fee model supports the micro-reward use cases central to TeachLink |
| 45 | +- The `wasm32-unknown-unknown` target produces compact, verifiable artifacts |
| 46 | + |
| 47 | +### Negative / Trade-offs |
| 48 | + |
| 49 | +- Soroban is a relatively new platform; the ecosystem of third-party libraries and auditors is smaller than EVM |
| 50 | +- Cross-chain bridge to EVM networks requires a custom bridge module, adding significant complexity |
| 51 | +- Windows development requires additional setup (MSVC toolchain or Docker) due to WASM linker limitations on MinGW |
| 52 | + |
| 53 | +### Neutral |
| 54 | + |
| 55 | +- The `wasm32-unknown-unknown` compile target is separate from native test compilation; developers must be aware of the two-target workflow (`cargo build --target wasm32-unknown-unknown` vs `cargo test`) |
| 56 | + |
| 57 | +## Implementation Notes |
| 58 | + |
| 59 | +**Affected modules:** |
| 60 | + |
| 61 | +- `contracts/teachlink/` (entire contract workspace) |
| 62 | + |
| 63 | +**Build command:** |
| 64 | + |
| 65 | +```bash |
| 66 | +cargo build --release --target wasm32-unknown-unknown -p teachlink-contract |
| 67 | +``` |
| 68 | + |
| 69 | +**Related issues / PRs:** Initial project setup |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## Review Checklist |
| 74 | + |
| 75 | +- [x] Context accurately describes the problem without solution bias |
| 76 | +- [x] Decision is stated clearly and unambiguously |
| 77 | +- [x] At least two alternatives are documented with rejection rationale |
| 78 | +- [x] Consequences cover both positive and negative outcomes |
| 79 | +- [x] Status field is set correctly |
| 80 | +- [x] Tags accurately reflect the domain |
| 81 | +- [x] Linked to the relevant GitHub issue or PR |
0 commit comments