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 .
-
Distribution System
- Main protocol entry point to start new community
- Based on Ethereum Distribution System
- Enables decentralized infrastructure deployment
- Main distributor: MAODistributor.sol
-
Token System
- RankToken: ERC1155 token for rank representation
- DistributableGovernanceERC20: ERC20 token for governance
- Rankify Token: ERC20 token implementing entrance gating
-
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
- Core Facets:
The MAO distribution (MAODistribution.sol) creates a complete infrastructure for a Meritocratic Autonomous Organization, including:
- Rank and governance tokens
- Autonomous Competence Identification Distribution
The Autonomous Competence Identification Distribution (ArguableVotingTournament.sol) implements:
- Turn-based game mechanics
- Voting and proposal systems
- EIP-712 compliant message signing
- Modular architecture
- Node.js (LTS version)
- pnpm package manager
- Git
-
Clone the repository:
git clone https://github.com/rankify-it/contracts.git cd contracts
-
Install dependencies:
pnpm install
-
Setup environment variables:
mkdir .secrets cp dev.env.sample .secrets/dev.env vi .secrets/dev.env # ... . ./.secrets/dev.env
-
Compile contracts:
pnpm build
-
Run tests:
pnpm test # or run tests in parallel pnpm test:parallel
-
Run linting:
pnpm lint # fix linting issues pnpm lint:fix
-
Clean build:
pnpm clean
- Deployment:
pnpm hardhat deploy --network <network> --tags ERC7744,MAO,rankify # or pnpm anvil:deploy # or : ./playbook/utils/deploy-to-local-anvil.sh
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.
-
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
Interactive playbook:
pnpm hardhat --network $NETWORK interactive
-
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
- Get all interfaces and signatures:
You can get all of the function signatures to debug your application from ./all-signatures.json
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 is generated via docgen and is available at docs.rankify.it
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Add your changes, add changeset:
pnpm changeset
- Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Create a Pull Request
This project is licensed under the MIT License.
For security concerns, please email [email protected]