In May 2021, we announced that OAK Network won the Web3 Foundation Open Grants Program to build a quadratic funding pallet for Polkadot. Today, we are excited to announce that the OAK team has completed the 2nd milestone and submitted it for review.
In summary, the goal of the grant is to implement Quadratic Funding, a common short name for Constrained Liberal Radicalism algorithm (referred to as CLR below). Proposed by Vitalik Buterin 2018, the CLR is a crowdfund matching mechanism for public goods such as open source projects, and has been widely adopted by Gitcoin on Ethereum.
The open source code of the Quadratic Funding pallet is available on Github. Note that the walk-through will use Polkadot.js web wallet to interact with the Quadratic Funding pallet, which you need to integrate into and run on a Substrate blockchain.
Without further ado, let’s start to go through the use case of this quadratic funding.
Step 1: Preparation
1. Prepare three wallets representing different user roles and name them Alice, Bob and Dave.
Alice — administrator, who represents registar and member of council of the blockchain. Don’t worry if you are familar about the term of roles. We will explain them later.
Bob — developer, who will create a project and apply for funding during the quadratic funding campaign.
Dave — end user, who would like to take part in a campaign by sponsoring projects.
2. Set Alice as an Identity verifier
According to the design of the quadratic funding pallet, only developers with on-chain identity set can submit a project for the funding. Assuming we are working on a new chain, we need to Alice as an identity verifier(called as registrar in Polkadot).
Open https://polkadot.js.org/apps/#/accounts, “Developer” -> “Sudo”, then call the “addRegistar” method in the “identity” module, specify the Alice’s address, click “Submit sudo”, sign And submit the transaction.
Once successful, you can call the “registrars” method in the “identity” module in “Developer” -> “Chain State” to see the array of registrars, and should be able to see Alice in it.
3. Use Alice to add initial funding into the campaign
Select “Developer” -> “Extrinsics”, then call the “fund” method in the “quadraticFunding” module, specify the Alice address, enter the amount of funds to be added, then sign and submit the transaction.
4. Make sure that Dave is funded
We will use Dave to take part in the campaign with voting later, so let’s send some tokens to Dave.
On the “Accounts” page, click the Send button on the far right of Alice, select Dave as “Send to address”, enter the amount to be transferred, and then sign and send the transaction.
Step 2: Set on-chain Identity for Bob
As we mentioned above, a project’s creator needs to have an on-chain Identity to submit, so here we use Bob to submit a “Set Identity” request and use registrar Alice to approve it.
On polkadot.js apps page, select the “Accounts” tab and select “Set on-chain identity” as shown below.
Enter Bob’s identity information and click the “Set Identity” button.
After the transaction is confirmed, there will be a gray minus sign to the left of the account name, indicating that the account has been authenticated but has not yet passed the review.
The identity request is submitted but not approved yet.
Use Bob to send a “requestJudgement” transaction.
Select “Developer” -> “Extrinsics”, then call the “requestJudgement” method in the “identity” module, specify the Bob account, enter the corresponding information (here RegistrarIndex is entered as 0(index of Alice), and max_fee is entered as 100), then sign and submit the transaction.
Use Alice to approve Bob’s identity request.
Select “Developer” -> “Extrinsics”, then call the “provideJudgement” method in the “identity” module, enter the corresponding information (Alice for “the selected account”, BOB for “target”, Reasonable for “judgement”), then sign and submit this transaction with Alice.
After the transaction is confirmed, you can see a green symbol on the left side of the Bob’s address, indicating that the identity verification is approved.
A green symbol on Bob means the identity is set of Bob.
Step 3: Bob creates a new project
Select “Developer” -> “Extrinsics”, then call the “createProject” method in the “quadraticFunding” module, enter the corresponding information, then sign and submit the transaction.
After the transaction is confirmed, you can see the created project information in “Developer” -> “Chain State” -> “quadraticFunding.projects”.
Step 4: Alice kicks off a campaign
Select “Developer” -> “Extrinsics”, and then call the “sudo” method in the “sudo” module, use the sudo module to call the “scheduleRound” method in the “quadraticFunding” module, enter the corresponding information, then sign and submit the transaction.
If successful, you can see the new round of campain in “Developer” -> “Chain State” ->“quadraticFunding.rounds”.
Step 5: Dave votes for Bob’s project
Once the campaign starts, select “Developer” -> “Extrinsics”, then call the “contribute” method in the “quadraticFunding” module, enter number 0 for project_index of Bob’s account and 10 for value, then sign and submit the transaction.
Once Dave’s voting is confirmed, you can view the latest donation information in “Storage” -> “quadraticFunding.rounds()”
Step 6: Alice finalizes the campaign
Now assuming it’s time for the end of the campaign, the administrator needs to finalize it and the result.
Select “Developer” -> “Extrinsics”, then call the “sudo” method in the “sudo” module, and call “quadraticFunding.finalizeRound”. Enter the round index, sign and submit this transaction.
After the transaction is sent, you can view the updated information of the current campaign in “Developer” -> “Storage”.
Step 7: Alice allows for funds withdrawal
Although the campaign is finalized and Bob has won the funding, we have one last step to go before actually dispensing the funds to Bob. Alice needs to call “quadraticFunding.approve” to allow Bob to withdraw. The approval process is put in place to allow for a granular funding based on milestone. For example, Alice can choose to dispense the first half of the funding initially and the 2nd half in the mid-term, or simply grant all the funds in the beginning.
Select “Developer” -> “Extrinsics”, and then call the “sudo” method in the “sudo” module, call “quadraticFunding.approve” , and enter Bob’s project_index as shown below.
After the transaction is confirmed, you can see in “Developer” -> “Chain State” that the Bob’s project is in a state where withdrawal is allowed.
Step 8: Bob withdraws the funds from the campaign
Select “Developer” -> “Extrinsics”, then call the “withdraw” method in the “quadraticFunding” module, enter the corresponding information, then sign and submit the transaction.
After the transaction is successful, you can see the status of the BOB project in “Developer” -> “Chain State”, which is already in the extracted state.
Now we have gone through the whole process of a Quadratic Funding campaign. If you have any questions, feel free to contact us from the Discord Server below. We’d love to hear your thoughts!
Thanks for reading!
Stay tuned for further information about the OAK Network here on Medium, Twitter and LinkedIn, as well as in our Discord Server!
Please check out our engineering and growth job openings, contact partner@oak.tech for partnerships, or contact@oak.tech for any general inquiries.
About Chris Li
Chris Li (LinkedIn) is the founder and CEO of Ava Protocol. Prior to establishing Ava Protocol, Chris gained valuable experience as a Messaging Protocol Engineer at Microsoft and as a successful serial entrepreneur. He is also a long-term EVM smart contract developer, Web3 Foundation grant recipient, and Polkadot core contributor.