Skip to content

jeronimotech/multando-blockchain

Repository files navigation

Multando Blockchain (Solana)

Solana Rust Anchor Python

Anchor smart contract for the MULTA token rewards system. Handles token distribution for verified traffic violation reports, staking with yield, and on-chain reward tracking.


Tech Stack

Layer Technology
Smart Contract Rust + Anchor 0.30.1
Blockchain Solana (devnet / mainnet-beta)
Token SPL Token (MULTA)
Python SDK solana-py, anchorpy
Testing Anchor test framework (TypeScript)

Smart Contract Instructions

The program exposes 5 instructions:

Instruction Description Accounts
initialize Set up the MULTA mint, vault, and program config Authority, Mint, Vault, Config
distribute_reward Send MULTA tokens to a user for a verified report Authority, Vault, UserTokenAccount
stake Lock MULTA tokens in the staking vault User, UserTokenAccount, StakeAccount
unstake Withdraw staked tokens after lock period expires User, StakeAccount, UserTokenAccount
claim_rewards Claim accumulated staking yield User, StakeAccount, Vault

Tokenomics

Parameter Value
Token Name MULTA
Total Supply 100,000,000
Decimals 6
Report Reward 1 - 50 MULTA (based on violation type and verification)
Staking APY 5%
Staking Lock Period 7 days
Reward Distribution Automatic via Celery worker on backend

Reward Tiers

Violation Type Base Reward Verified Bonus
Illegal Parking 5 MULTA +2 MULTA
Double Parking 8 MULTA +3 MULTA
Running Red Light 15 MULTA +5 MULTA
Blocking Crosswalk 10 MULTA +4 MULTA
Speeding 20 MULTA +10 MULTA

Project Structure

services/blockchain/
  programs/
    multando/
      src/
        lib.rs              # Program entry point
        instructions/        # Instruction handlers
        state/               # Account structs
        errors.rs            # Custom error codes
  sdk/
    python/
      multa_client.py       # Async Python SDK
      types.py              # Pydantic models
  scripts/
    deploy-devnet.sh        # Devnet deployment script
    initialize-mint.py      # Mint initialization
  tests/
    multando.ts             # Integration tests
  migrations/               # Anchor migrations
  Anchor.toml               # Anchor config
  Cargo.toml                # Rust dependencies

Quick Start

Prerequisites

  • Rust 1.75+
  • Solana CLI 1.17+
  • Anchor CLI 0.30.1
  • Node.js 18+ (for tests)

Build and Test

# Build the program
anchor build

# Run tests (starts local validator automatically)
anchor test

# Deploy to devnet
./scripts/deploy-devnet.sh

Deploy to Devnet

# Configure Solana CLI for devnet
solana config set --url devnet

# Airdrop SOL for deployment fees
solana airdrop 2

# Deploy
./scripts/deploy-devnet.sh

The script will:

  1. Build the program
  2. Deploy to devnet
  3. Initialize the MULTA mint
  4. Create the vault and config accounts
  5. Print the program ID and mint address

Python SDK

The Python SDK provides an async client for interacting with the on-chain program from the backend API.

Installation

pip install solana anchorpy

Usage

from sdk.python.multa_client import MultaClient

client = MultaClient(
    rpc_url="https://api.devnet.solana.com",
    program_id="MULTA_PROGRAM_ID",
    authority_keypair=authority_keypair,
)

# Distribute reward to a user
await client.distribute_reward(
    user_pubkey=user_wallet,
    amount=5_000_000,  # 5 MULTA (6 decimals)
    report_id="report_abc123",
)

# Check balance
balance = await client.get_balance(user_wallet)

# Stake tokens
await client.stake(user_keypair, amount=100_000_000)  # 100 MULTA

# Get staking info
stake_info = await client.get_stake_info(user_wallet)

MultaClient Methods

Method Description
initialize() Set up mint, vault, and config (one-time)
distribute_reward(user, amount, report_id) Send MULTA to user
get_balance(user) Get MULTA token balance
stake(user, amount) Stake MULTA tokens
unstake(user) Withdraw staked tokens
claim_rewards(user) Claim staking yield
get_stake_info(user) Get staking account details
get_config() Read program configuration
get_mint_info() Read MULTA mint metadata

Go-Live Checklist

  • Audit smart contract (third-party security audit)
  • Deploy to mainnet-beta
  • Update program ID in backend .env
  • Verify program on Solana Explorer
  • Transfer mint authority to multisig
  • Set up monitoring for program transactions
  • Configure rate limits on RPC provider
  • Test reward distribution end-to-end on mainnet
  • Enable staking UI in web and mobile apps
  • Publish token metadata to Metaplex

License

All rights reserved. Proprietary software.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages