During this workshop, we will build a smart contract that handles voting with multiple users calling the contract to vote. This demo is DAO-esque, demonstrating many of features that would be used in a full DAO voting contract.
We are writing a smart contract for a group of people who love numbers! They want to be able to keep track of the group's current favorite number and vote on new favorite numbers. The contract will use a governance token to allocate votes, and will allow users to deposit tokens, withdraw tokens, vote on a new favorite number, and execute the contract to count the votes and set a new favorite number.
- Download this repo
- Get set up
- Set up your editor
- Check out the Sway primer (optional, but recommended)
- Build the Asset contract
- Build the Fundraiser contract
-
Install
cargo
usingrustup
Mac and Linux:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
-
Check for correct setup:
$ cargo --version cargo 1.62.0
-
Install
forc
usingfuelup
Mac and Linux:
curl --proto '=https' --tlsv1.2 -sSf \ https://fuellabs.github.io/fuelup/fuelup-init.sh | sh
-
Check for correct setup:
$ forc --version forc 0.18.1
if that doesn't work
You are welcome to use your editor of choice.