Flow Community Rewards are here. Earn points for engaging in the ecosystem, spend points on prizes. Learn more.
Ecosystem
April 2, 2020
Cadence Cup Round 2: Building Voting Mechanisms
Flow
Cadence Cup Round 2: Building Voting Mechanisms

It’s been an exciting week wrapping up Round 1 of the Cup and making fixes and updates to the Flow Playground.

Cadence Cup Round 2 is here, along with improvements and fixes to Cadence and the Flow Playground. If you submitted to Round 1, amazing. We hope you had a great time designing and building your NFT smart contracts and creative minters. Let’s see you flex your skills again in Round 2. 

New to Cadence Cup? No worries! Start where you are and get cracking on a project for this week’s challenge.  

Continuing the theme of the first challenge, Round 2 is all about how blockchains and smart contracts can help us connect with each other even if we are physically separated. How can we share our ideas and goals when we’re apart? 

The challenge if you choose to accept it is: Create a smart contract that uses resources that enables groups to vote on various actions and outcomes. There are many different types of voting mechanics, and you can choose any one you want, or better yet make up one on your own. Voting is one part of creating a system of governance using Smart Contracts. We believe that governance is one of the most compelling use-cases for Smart Contracts in general.

Here is a voting tutorial that outlines a very simple example of a voting contract. In this tutorial, we walk you through creating a simple Approval Voting smart contract, show you how to directly transfer a resource object by having two accounts sign the transaction, and tally votes. You can use this as a starting point, or come up with something completely new! It's all up to you. 

Talk to Me About Judging

Judges will score each project on readability, effectiveness, and creativity. We'll be there to assist you along the way. If you have any questions during this challenge, please post them in the #developer channel on Discord.

Don’t Forget to Submit On Time

You may have noticed an extra week was added to the Round 1 challenge. We hear you that you might need a little more time for your projects, so the Round 2 challenge will also span 2 weeks. 

Start Date for Round 2 Challenge: April 2, 2020

End Date for Round 2 Challenge: April 15, 2020 (11:59 PM PST - time subject to change)

SUBMIT YOUR ENTRY FOR CADENCE CUP Round 2 HERE.

Rules of Cadence Cup

  • The project with the highest amount of points at the end of each round wins a prize for that round
  • Members of the Flow team, and sometimes prominent members of the community, will give each project a score based on: readability, effectiveness, and creativity of the contract
  • We previously said the max score a project can receive for each challenge is 15 points (5 being the highest in each category), but we switched it up to a simpler system: 5 points for legit participation, 7 points for submitting a good project, 10 points for a win

Prizes of Cadence Cup

  • Each round, the winning project will receive a Cadence Builder Kitty
  • At the end of three rounds, the individual with the highest score will receive $2500
  • If you submit a project every round and receive a combined score of 20 and above, you'll also receive a Cadence Builder Kitty

Updates to the Playground

  • New Cadence runtime. (Breaking changes. See below ⚠)
  • Many UI tweaks and fixes including better error messages (with line numbers!).

To help you complete your projects for the second challenge and to continue improving Cadence and the playground, we are also releasing an update to the Cadence runtime and the playground that fixes bugs and introduces some improvements and breaking changes to the language. Many contracts and transactions that worked in the previous version of the playground will need to be updated with the changes.

Breaking changes:

See the #general channel in the Flow Discord for a deeper explanation of these changes with examples.

  • In `prepare` block parameters in transactions, `Account` has been replaced by `AuthAccount`.
    The type has been renamed to prevent ambiguity with public accounts (`PublicAccount`) and make it clearer that such an account allows full access to its storage and public keys.
  • Using resource interfaces as types is not supported anymore. Instead, use a restricted resource. `@AnyResource{RI}`


🌟Enhancements

  • Cadence:
    Extended failable casting (`as?`)
    Added force casting (`as!`)
  • Added postfix force unwrapping operator for optionals (`!`), which returns the inner value of an optional. If the optional is `nil`, the program aborts.
  • Added the force assignment/move operator `<-!`, which forces assignment of a resource to a target. If the target is non-`nil`, the program aborts.
  • Extended set of valid as dictionary key types: all number types, addresses, and characters are supported now
  • Extended event parameter types: all number types, addresses, characters, dictionaries, and optional types are supported now
  • Various bugfixes for fixed-point numbers, references, and others

These changes will not affect how we judge the Cadence Cup entries from Round 1, but in order for your code to still work for you, you will need to update it to reflect these breaking changes.