TTTTT eeeee aaaaa ccccc h h L i n n k k
T e a a c h h L nn n k k
T eeee aaaaa c hhhhh L i n n n kkk
T e a a c h h L i n nn k k
T eeeee a a ccccc h h LLLLL i n n k k
TeachLink is a Soroban smart contract that powers tokenized learning rewards on the Stellar network. This repository contains the Rust smart contract and developer tooling for building, testing, and deploying the contract to Stellar testnet or mainnet.
- Overview
- Interactive Documentation
- Onboarding
- Developer Experience Toolkit
- Architecture
- Development Workflow
- Contribution Guidelines
- Troubleshooting
- License
TeachLink enables tokenized learning rewards, proof-of-participation, and educator incentives. The contract is written in Rust for Soroban, Stellar's smart contract platform.
Explore the TeachLink contract interactively with live code execution, API exploration, and guided tutorials. The interactive documentation provides an engaging way to understand the contract's architecture and implementation.
To run the interactive docs:
cd docs/interactive
cargo runThen open http://localhost:3000 in your browser.
The onboarding flow is designed to take you from clone to first deployment with minimal guesswork.
git clone https://github.com/rinafcode/teachLink_contract.git
cd teachLink_contractRun the setup script to validate required dependencies and create a local .env file if needed:
./scripts/setup-env.shWhat it checks:
rustc,cargo, andrustupwasm32-unknown-unknowntargetstellarorsorobanCLI- local
.envbootstrap from.env.example
Update .env with your deployment settings:
STELLAR_NETWORK=testnet
STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
STELLAR_SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
DEPLOYER_SECRET_KEY=SXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXIf you do not have a key, generate one with the Stellar CLI:
stellar keys generate --global teachlink-deployercargo build --release --target wasm32-unknown-unknown -p teachlink-contract
cargo testThe tutorial script walks you through building, funding, and deploying to testnet:
./scripts/first-deploy.shCommon options:
./scripts/first-deploy.sh --network testnet --identity teachlink-deployer
./scripts/first-deploy.sh --skip-build
./scripts/first-deploy.sh --dry-runUse the network-aware deployment script with managed config files:
./scripts/deploy.sh --network testnet
./scripts/deploy.sh --network mainnet
./scripts/deploy.sh --network localConvenience wrappers:
./scripts/deploy-testnet.sh
./scripts/deploy-mainnet.sh
./scripts/deploy-local.shConfiguration files live under config/networks/ and can be customized per environment:
config/networks/testnet.env
config/networks/mainnet.env
config/networks/local.envTeachLink provides a comprehensive set of tools to streamline your development workflow, from environment setup to deployment.
Validate your development environment with version checks and system requirements:
./scripts/validate-env.shThis enhanced validation script checks:
- Core dependencies (Rust, Cargo, Rustup) with minimum version requirements
- WASM target installation
- Stellar/Soroban CLI availability
- System resources (disk space)
- Optional tools (Docker, Git)
- Environment configuration (.env file)
Install all required dependencies automatically:
./scripts/install-deps.shThis interactive script will:
- Install Rust toolchain via rustup (if missing)
- Add wasm32-unknown-unknown target
- Install Stellar CLI
- Update Rust components (rustfmt, clippy)
- Provide Docker installation instructions
- Check for additional development tools
Build all contracts or a specific contract:
./scripts/build.sh # Build all contracts (debug mode)
./scripts/build.sh --release # Build with optimizations
./scripts/build.sh --contract teachlink # Build specific contract
./scripts/build.sh --verbose # Verbose outputExecute unit tests with various options:
./scripts/test.sh # Run all tests
./scripts/test.sh --contract teachlink # Test specific contract
./scripts/test.sh --verbose # Verbose test output
./scripts/test.sh --nocapture # Show println! outputCheck and fix code style issues:
./scripts/lint.sh # Format code and run clippy
./scripts/lint.sh --check # Check formatting only
./scripts/lint.sh --fix # Auto-fix clippy suggestionsRemove build artifacts to free disk space:
./scripts/clean.sh # Standard clean (target dir)
./scripts/clean.sh --deep # Deep clean (includes cargo cache)Run a full development workflow (validate, build, test, lint):
./scripts/dev.sh # Full development cycle
./scripts/dev.sh --release # Full cycle with release build
./scripts/dev.sh --skip-test # Skip tests
./scripts/dev.sh --watch # Watch mode (requires cargo-watch)Work in a fully containerized environment with all dependencies pre-installed:
# Start development environment
docker-compose up dev
docker-compose exec dev bash
# Build WASM in container
docker-compose run --rm builder
# Run tests in container
docker-compose run --rm test
# Run linter in container
docker-compose run --rm lint
# Clean up
docker-compose down -v# Build development image
docker build --target development -t teachlink-dev .
# Run interactive container
docker run -it --rm -v $(pwd):/workspace teachlink-dev
# Build contracts in container
docker run --rm -v $(pwd):/workspace teachlink-dev cargo build --release --target wasm32-unknown-unknown- Initial Setup: Run
./scripts/install-deps.shand./scripts/validate-env.sh - Before Coding: Pull latest changes and run
./scripts/dev.shto ensure environment works - During Development: Use
./scripts/dev.sh --watchfor continuous feedback - Before Committing: Run
./scripts/dev.sh --releaseto catch all issues - CI/CD Integration: Use Docker containers for consistent builds across environments
Client Apps
|
v
Indexer / API Layer (optional)
|
v
Soroban Smart Contract (Rust)
|
v
Stellar Network
Key project paths:
contracts/teachlink: Soroban smart contract sourcescripts/: onboarding and deployment script
# Complete development cycle
./scripts/dev.sh
# Individual steps
./scripts/build.sh --release # Build WASM
./scripts/test.sh # Run tests
./scripts/lint.sh # Format and lintBuild the WASM:
cargo build --release --target wasm32-unknown-unknown -p teachlink-contractRun unit tests:
cargo testLint and format:
cargo fmt
cargo clippy --all-targets --all-featuresdocker-compose run --rm builder # Build WASM
docker-compose run --rm test # Run tests
docker-compose run --rm lint # Lint codeWe welcome contributions that improve contract quality, developer experience, and documentation.
- Fork the repo and create a feature branch.
- Make focused changes with tests.
- Run the full test and lint suite.
- Open a PR with a clear summary and testing notes.
When adding contract entrypoints, include unit tests in the same module or under #[cfg(test)]:
#[contractimpl]
impl TeachLinkContract {
#[must_use]
pub fn hello(_env: Env, to: Symbol) -> Symbol {
to
}
}
#[test]
fn hello_returns_input() {
let env = Env::default();
let input = Symbol::new(&env, "teachlink");
let out = TeachLinkContract::hello(env.clone(), input);
assert_eq!(out, Symbol::new(&env, "teachlink"));
}- All new contract logic must include unit tests.
cargo testmust pass.cargo fmtandcargo clippy --all-targets --all-featuresmust pass with no new warnings.
-
Run enhanced environment validation:
./scripts/validate-env.sh
-
If validation fails, try automated installation:
./scripts/install-deps.sh
-
For legacy validation (minimal checks):
./scripts/setup-env.sh
Missing command: stellar or soroban- Install the CLI:
cargo install --locked stellar-cli --features opt
- Install the CLI:
Rust target not installed: wasm32-unknown-unknown- Run:
rustup target add wasm32-unknown-unknown
- Run:
WASM not foundduring deployment- Rebuild:
cargo build --release --target wasm32-unknown-unknown -p teachlink-contract - Verify the path:
target/wasm32-unknown-unknown/release/teachlink_contract.wasm
- Rebuild:
DEPLOYER_SECRET_KEYis empty- Generate a key:
stellar keys generate --global teachlink-deployer - Update
.envwith the secret key
- Generate a key:
Account not fundedortransaction failedon testnet- Re-run the tutorial without
--skip-fund - Or fund manually:
https://friendbot.stellar.org?addr=<PUBLIC_KEY>
- Re-run the tutorial without
curl not foundwhile funding- Install curl or fund the account manually using the friendbot URL
This project is licensed under the MIT License. See LICENSE for details.