Skip to content

Latest commit

 

History

History
182 lines (137 loc) · 5.79 KB

README.md

File metadata and controls

182 lines (137 loc) · 5.79 KB

Rankify Contracts

Smart contract infrastructure for rankify.it - A platform for building bottom-up self-organized organizations with use of autonomous competence identification and continuous voting proposing protocols .

Overview

Rankify Contracts provide the foundation for creating and managing Meritocratic Autonomous Organizations (MAO) using a tournament system for autonomous competence identification. The system leverages the Diamond pattern for upgradeable smart contracts and integrates with Ethereum Distribution System toi deploy governance tokens compatible with governance frameworks like Aragon OSx or OpenZeppelin.

Architecture

Core Components

  1. Distribution System

  2. Token System

  3. Diamond Pattern Implementation

    • Core Facets:
      • EIP712InspectorFacet: EIP-712 message signing and verification
      • RankifyInstanceMainFacet: Tournament core logic
      • RankifyInstanceGameMastersFacet: Voting and proposal mechanics
      • RankifyInstanceRequirementsFacet: Participation requirements
      • DiamondLoupeFacet: Facet introspection
      • OwnershipFacet: Contract ownership management

Available Distributions

1. Meritocratic Autonomous Organization (MAO)

The MAO distribution (MAODistribution.sol) creates a complete infrastructure for a Meritocratic Autonomous Organization, including:

  • Rank and governance tokens
  • ACID Distribution system
  • Token voting capabilities

2. ACID Distribution

The Autonomous Competence Identification Distribution (ArguableVotingTournament.sol) implements:

  • Turn-based game mechanics
  • Voting and proposal systems
  • EIP-712 compliant message signing
  • Modular architecture

Development Setup

Prerequisites

  • Node.js (LTS version)
  • pnpm package manager
  • Git

Installation

  1. Clone the repository:

    git clone https://github.com/rankify-it/contracts.git
    cd contracts
  2. Install dependencies:

    pnpm install
  3. Setup environment variables:

    mkdir .secrets
    cp dev.env.sample .secrets/dev.env
    vi .secrets/dev.env
    # ...
    . ./.secrets/dev.env

Build and Test

  1. Compile contracts:

    pnpm build
  2. Run tests:

    pnpm test
    # or run tests in parallel
    pnpm test:parallel
  3. Run linting:

    pnpm lint
    # fix linting issues
    pnpm lint:fix

Deployment

  1. Deployment:
    # deploy EDS dependency (only once per network)
    git clone https://github.com/peeramid-labs/eds.git
    cd eds
    latestTag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
    git checkout $latestTag
    pnpm install && pnpm hardhat deploy --network <network> --tags code_index
    cd ..
    
    pnpm hardhat deploy --network <network> --tags <tags>
    # or
    pnpm anvil:deploy
    # or to run next step:
    ./playbook/utils/deploy-to-local-anvil.sh

Interacting with Contracts

We provide helper tools in form of playbooks - small hardhat runtime scripts that can be used to set contract state for sake of testing and verification.

  1. Running local playbooks:
    pnpm hardhat --network $NETWORK addDistribution
    pnpm hardhat --network $NETWORK createSubject --token-name xxx
    pnpm hardhat --network $NETWORK createGame --rankify-instance-address $INSTANCE_ADDRESS
  2. Using viem to interact with contracts:

In (abi)[./abi] directory you can find generated abi files for all contracts, including .ts files to give viem/wagmi a better experience.

Copy these files to your working project and import them using import { ... } from './abi/...';

We provide this packaged within our sdk: @peeramid-labs/sdk

  1. Get all interfaces and signatures:

You can get all of the function signatures to debug your application via the following command:

pnpm hardhat getSuperInterface > interface.json

This will generate a file called interface.json in the current directory.

You can also use script in ./scripts/getSuperInterface.ts to get ethers js object

Project Structure

contracts/
├── src/                    # Smart contract source files
│   ├── abstracts/         # Abstract contracts
│   ├── distributions/     # Distribution implementations
│   ├── facets/           # Diamond pattern facets
│   ├── interfaces/       # Contract interfaces
│   ├── libraries/        # Shared libraries
│   └── tokens/           # Token implementations
├── test/                  # Test files
├── scripts/              # Deployment and utility scripts
└── deployments/          # Deployment artifacts

Documentation

Documentation is generated via docgen and is available at docs.rankify.it

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Add your changes, add changeset: pnpm changeset
  4. Commit your changes (git commit -m 'Add some amazing feature')
  5. Push to the branch (git push origin feature/amazing-feature)
  6. Create a Pull Request

License

This project is licensed under the MIT License.

Security

For security concerns, please email [email protected]