Skip to content

A substrate pallet prototype for a quadratic funding grant

License

Notifications You must be signed in to change notification settings

zhangjiannan/QFgrant

Repository files navigation

QuadraticFunding pallet based on substrate

A fresh pallet which implements quadratic voting and funding using Substrate. 🚀

Getting Started

This project contains is developed with Rust, please make sure you have set up rust correctly before running and testing. A detailed test guide can be found here

Rust Setup

Follow the Rust setup instructions before using the included Makefile to build the Node Template.

Makefile

This project uses a Makefile to document helpful commands and make it easier to execute them. Get started by running these make targets:

  1. make init - Run the init script to configure the Rust toolchain for WebAssembly compilation.
  2. make run - Build and launch this project in development mode.

The init script and Makefile both specify the version of the Rust nightly compiler that this project depends on.

Build

The make run command will perform an initial build. Use the following command to build the node without launching it:

make build

Test & Run

The make test command will run all the test cases in tests.rs.

The make run command will launch a temporary node and its state will be discarded after you terminate the process. After the project has been built, there are other ways to launch the node.

Pallet Structure

The pallet follows official pallet develop guide, we'll skip the step-by-step guide and only focus on it's storage and functions.

Storage

  • Rounds map Stores a unsigned interger index as key with a round struct as value. The round struct contains information about funding pool, status and support_area etc.
  • Projects double_map Using (round_id, project_hash) as key, the value is a project struct.
  • ProjectVotes double_map Using (vote_hash, account) as key, the values is number of votes this account has voted for this project.
Note: We should NOT use project_hash as the first key of ProjectVotes, as projects with same hash may exist in multiple ongoing rounds, which will lead to misfunction of vote.

Functions

  • start_round, The pallet admin can open a new round
  • donate, Donate some tokens to some specific round
  • register_project, Register your projects to some ongoing rounds
  • vote, Vote to a project in some ongoing rounds
  • vote_cost, Calculate estimated cost for any willing ballots, this function will NOT update storage. In order to get value, frontend should subscribe its events.
  • end_round, The pallet admin can close an existing round, the fund in pool will be distributed to those voted projects accordingly.

Changelog

  • 2021.03.08 Implements multi-round voting mechanism, which allows admin users to open several rounds of QF at the same time
  • 2020.03.01 Basic quadratic voting and funding logics, including set up charging fee and project name

About

A substrate pallet prototype for a quadratic funding grant

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages