Skip to content

PollD is a dApp that allows users to create polls with an unlimited amount of options to choose from.

Notifications You must be signed in to change notification settings

Kilo-Loco/PollD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PollD

PollD is a dApp that allows users to create polls with an unlimited amount of options to choose from. PollD only allows for a single option to be selected for each poll and a user (wallet) can only vote once.

To view the deployed contract, visit Etherscan (Sepolia).

You can interact with the PollDApp smart contract using the following functions:

Call

  • getPollCount(): Returns the total amount of polls and the last PollID used.
  • getPoll(uint)(PollDetails): Get relevant information of a Poll by its ID.

Send

  • createPoll(string,string[]): Creates a Poll given the question and an array of options to choose from.
  • vote(uint256,uint256): Allows a user to vote given the PollID and the option index.
Structures
struct PollOption {
    uint pollId;
    uint optionIndex;
    string title;
    uint voteCount;
}

struct PollDetails {
    uint id;
    address creator;
    string question;
    uint expDate;
    PollOption[] options;
}

Usage

To easily interact with PollD, you can use the make commands located in the Makefile.

You can also interact with the contract directly from Foundry. Those examples will be listed in dropdowns.

Build

Foundryup must be running to build the project:

$ make start

In the root directory of the project, run the following command to compile the project:

$ make build
Build using Foundry
$ foundryup
$ forge build

Test

$ make tests
Test using Foundry
$ forge test

Deploy

$ make deploy
Deploy using Foundry
$ forge script script/DeployPollDApp.s.sol\
    --rpc-url <RPC_URL>\
    --broadcast\
    --account <ERC_2335_KEY>\
    --sender  <WALLET_ADDRESS>

Interaction

Create a local testnet node:

$ make local-chain

Get Poll Count

$ make get-poll-count

Get A Poll

$ make get-poll

Create A Poll

$ make create-poll

Vote On A Poll

$ make vote

PollD creates a config file for storing both the contract_address and rpc_urlwhich are fields required for most interactions with the dApp. If you need to clear the config, run the following command:

$ make clear-config
Interact using Foundry
$ anvil

Example Send

$ cast send <CONTRACT_ADDRESS>\
    "createPoll(string,string[])" "Favorite color?" "['red','blue','yellow']"\
    --rpc-url <RPC_URL>\
    --account <ERC_2335_KEY>

Example Call

$ cast call <CONTRACT_ADDRESS>\
    "getPoll(uint)(uint,address,string,uint)" 1
Create ERC-2335 Key
$ cast wallet import <KEY_NAME> --private-key <WALLET_PRIVATE_KEY>

Requirements

To install Foundryup, run the following command in your terminal:

$ make install-foundry

OR

$ curl -L https://foundry.paradigm.xyz | bash

About

PollD is a dApp that allows users to create polls with an unlimited amount of options to choose from.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published