Skip to content

ecotask-network/EcoTask-contract

Repository files navigation

🔗 ecotask-contracts

The on-chain heart of EcoTask — smart contracts powering verifiable climate rewards.

Stellar Soroban contracts written in Rust that handle token issuance, task registration, and trustless reward distribution.

Build Rust Soroban License: MIT Status


🌍 Overview

ecotask-contracts contains the Soroban smart contracts that power the trustless, transparent reward system at the core of EcoTask.

These contracts run on the Stellar blockchain and are responsible for:

  • 🪙 Issuing and managing the ECO token
  • 📋 Registering tasks and their reward parameters on-chain
  • 🔍 Processing verifications and releasing rewards automatically
  • 🗳️ Future DAO governance for platform decisions

Every reward payout is transparent, auditable, and trustless — no middleman, no delays, no corruption.


📦 Contracts

1. eco-token

The EcoTask native token contract.

  • Issues ECO tokens tied to verified environmental impact
  • Controls minting — only the reward engine can mint new tokens
  • Implements the Stellar token interface (SEP-0041 compatible)
  • Supports token metadata: name, symbol, decimals

2. task-registry

The on-chain task database.

  • Stores task definitions: type, location hash, reward amount, expiry
  • Controls who can create tasks (admins, verified NGOs, sponsors)
  • Emits events when tasks are created, completed, or expired
  • Prevents double-claiming — tracks which wallets completed which tasks

3. reward-engine

The verification and payout engine.

  • Receives verification results from the off-chain oracle
  • Validates proof hashes against IPFS CIDs stored at submission
  • Mints ECO tokens or transfers USDC to the user's wallet on success
  • Handles disputes and partial rewards for incomplete tasks

🚀 Quick Start for Contributors

Get up and running in minutes:

  1. Install Prerequisites:
    rustup target add wasm32v1-none
    cargo install --locked soroban-cli
  2. Clone & Build:
    git clone https://github.com/ecotask/ecotask-contracts.git
    cd ecotask-contracts
    make build
  3. Run Tests:
    make test

For more details, see CONTRIBUTING.md.

🤝 Contributing

We welcome contributions! Please see our Contributing Guidelines and Code of Conduct for more information on how to get involved.


🏗️ Folder Structure

ecotask-contracts/
├── contracts/
│   ├── eco-token/
│   │   ├── src/
│   │   │   ├── lib.rs            # Contract entry point
│   │   │   ├── token.rs          # Token logic (mint, transfer, burn, approve)
│   │   │   └── storage.rs        # On-chain state management
│   │   └── Cargo.toml
│   │
│   ├── task-registry/
│   │   ├── src/
│   │   │   ├── lib.rs            # Contract entry point
│   │   │   ├── registry.rs       # Task CRUD operations
│   │   │   ├── access.rs         # Role-based access control
│   │   │   └── storage.rs        # On-chain state management
│   │   └── Cargo.toml
│   │
│   └── reward-engine/
│       ├── src/
│       │   ├── lib.rs            # Contract entry point
│       │   ├── verification.rs   # Proof validation and reward logic
│       │   └── storage.rs        # On-chain state management
│       ├── tests/
│       │   └── full_lifecycle_test.rs  # Cross-contract integration tests
│       └── Cargo.toml
│
├── scripts/
│   ├── deploy.sh                 # Deploy contracts to testnet/mainnet
│   ├── invoke.sh                 # Helper to call contract functions
│   ├── fund-accounts.sh          # Fund test accounts with friendbot
│   ├── verify-deploy.sh          # Verify deployed contract state
│   └── integration-test.sh       # End-to-end integration test runner
│
├── .github/
│   └── workflows/
│       └── ci.yml                # CI pipeline (build, test, lint, fmt)
│
├── Cargo.toml                    # Workspace config
└── README.md

🚀 Getting Started

Prerequisites

# Install Soroban CLI
cargo install --locked soroban-cli

# Add the WebAssembly target
rustup target add wasm32v1-none

Build

# Clone the repo
git clone https://github.com/ecotask-network/ecotask-contracts.git
cd ecotask-contracts

# Build all contracts
cargo build --target wasm32v1-none --release

# Build a specific contract
cd contracts/eco-token
cargo build --target wasm32v1-none --release

Test

# Run all tests
cargo test

# Run tests for a specific contract
cargo test -p eco-token
cargo test -p task-registry
cargo test -p reward-engine

Deploy to Testnet

# Configure Soroban CLI for testnet
soroban network add testnet \
  --rpc-url https://soroban-testnet.stellar.org \
  --network-passphrase "Test SDF Network ; September 2015"

# Deploy the ECO token contract
soroban contract deploy \
  --wasm target/wasm32v1-none/release/eco_token.wasm \
  --network testnet \
  --source YOUR_SECRET_KEY

# Note the contract ID and add to your .env

🔐 Contract Architecture

                        ┌─────────────────┐
                        │   Task Registry  │
                        │                 │
                        │ • Store tasks   │
                        │ • Track claims  │
                        └────────┬────────┘
                                 │ task data
                                 ▼
User submits proof ──▶  ┌─────────────────┐     ┌──────────────┐
(off-chain oracle)      │  Reward Engine  │────▶│  ECO Token   │
                        │                 │mint  │              │
                        │ • Verify proof  │     │ • Mint ECO   │
                        │ • Check task    │     │ • Transfer   │
                        │ • Release pay   │     └──────────────┘
                        └─────────────────┘
                                 │ USDC transfer
                                 ▼
                        ┌─────────────────┐
                        │  User Wallet    │
                        │  (Stellar)      │
                        └─────────────────┘

🧪 Example: Calling the Reward Engine

# Invoke the reward engine to process a verified task
soroban contract invoke \
  --id YOUR_REWARD_ENGINE_CONTRACT_ID \
  --network testnet \
  --source YOUR_SECRET_KEY \
  -- \
  process_reward \
  --user GUSER_PUBLIC_KEY \
  --task_id "task_001" \
  --proof_cid "QmXyz...ipfs_hash" \
  --reward_amount 100

🔒 Security

  • All contracts are designed for formal audit before mainnet deployment
  • Minting is restricted to the reward engine contract only
  • Task creation requires an admin or verified sponsor signature
  • Proof hashes are stored at submission time to prevent retroactive fraud
  • See SECURITY.md to report vulnerabilities

🤝 Contributing

Rust and Soroban experience helpful but not required — we're happy to mentor. See CONTRIBUTING.md to get started.


📄 License

MIT — see LICENSE for details.


Ecosystem

This is part of the EcoTask Network:

Repo Description
EcoTask-app Mobile dApp
EcoTask-backend Node.js API & verification engine
EcoTask-contracts Stellar Soroban smart contracts
EcoTask-docs Documentation hub

Part of the EcoTask Network — Because the environment deserves an economy.

About

EcoTask Network smart contracts — a Soroban (Stellar) suite for decentralized environmental action. Features: ECO token (SEP-41 standard) for carbon-backed rewards, task registry with sponsor-based creation, completion tracking, expiry, and proof-of-action verification via oracle-based reward engine.

Resources

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages