Skip to content

commune-ai/commune

Folders and files

NameName
Last commit message
Last commit date

Latest commit

5a65e80 Β· Jan 18, 2025
Mar 20, 2024
Jan 18, 2025
Jan 16, 2025
Jan 16, 2025
Jan 16, 2025
Aug 20, 2024
Aug 20, 2024
Jan 16, 2025
Jan 16, 2025
Dec 14, 2024
Jan 13, 2025
Jan 16, 2025

Repository files navigation

Commune: Incentivizing Applications in a Multichain World

Commune is a modular consensus system designed to incentivize applications to run on networks through innovative token models and bonding curves. It provides a flexible framework for building and managing distributed applications across multiple chains.

πŸš€ Quick Start

Installation

Requirements:

  • Python 3.10+
  • NodeJS 14+
  • npm 6+
# Clone the repository
git clone https://github.com/commune-ai/commune.git

# Install the package
cd commune
pip install -e ./

# Install npm dependencies
chmod +x ./scripts/*
sudo ./scripts/install_npm_env.sh

Basic Usage

import commune as c

# Create a new module
c.new_module('agi')

# Serve a module
c.serve('agi')

# Call a module
c.call('agi/forward', "hello")

πŸ—οΈ Core Concepts

Modules

A module is a collection of functions and state variables. Modules are the building blocks of Commune and can be:

  • Served as HTTP endpoints
  • Called remotely
  • Managed through the CLI
  • Inherited and extended

Networks

Networks in Commune consist of:

  • Namespace: Maps server names to addresses
  • Servers: Modules exposed as network endpoints
  • Validators: Nodes that validate and secure the network

Keys

Commune uses SR25519 keys for:

  • Signing messages
  • Encrypting/decrypting data
  • Cross-chain compatibility
  • Creating temporary tokens

πŸ’» CLI Interface

Commune provides a Pythonic CLI for interacting with the system:

# Create a new module
c new_module agi

# Serve a module
c serve agi

# List modules
c modules

# Get module info
c module_info agi

πŸ”— Network Features

Validator System

  • Staking: Token-based staking with rewards
  • Anti-Rug Mechanism: Prevents pump and dump schemes
  • Price Controls: Min/max pricing and stop loss mechanisms
  • Subnet Management: Create and manage subnets with locked liquidity

Token Economics

  • Bonding curves for price discovery
  • Token emission vs native emission
  • Cross-chain token locking
  • User-to-user token lending

πŸ› οΈ Development

Creating a Module

import commune as c

class MyModule(c.Module):
    def __init__(self, param1=1):
        self.set_config(locals())
    
    def forward(self, x):
        return x * self.config.param1

Serving a Module

# Serve on local network
c.serve('mymodule', network='local')

# Serve on Subspace network
c.serve('mymodule', network='subspace', netuid=0)

πŸ“š Documentation

For more detailed documentation, please see:

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.