Skip to content

jinhanloh2021/smub-dao-front

Repository files navigation


SMUB DAO

SMU Blockchain DAO

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Code Rundown
  5. Roadmap
  6. Contributing
  7. Contact
  8. Acknowledgments

About The Project

SMUB DAO Frontend

This website is for interacting with the Governance smart contracts deployed on the Sepolia Network. The DAO contract can be found at this address. The main functionalities of the DAO is creating proposals and voting, which can be done through the website. The proposal is currently hardcoded to setExco, with no form to change the description or other function arguments.

The remaining functions such as voting, queueing and executing are all hardcoded to test the functionality of the smart contract on the testnet.

A future improvement would be to make the functions more dynamic, allowing people to vote against, see the proposal status and discuss on proposals. This beta version is just a proof of concept.

Checkout the DAO contracts, deployment and testing scripts at this repo.

YouTube walkthrough here

Built With

  • NextJs
  • Ethers
  • Tailwind
  • Shadcn

(back to top)

Getting Started

To get a local copy up and running follow these simple example steps.

Prerequisites

  • npm
    npm install npm@latest -g
  • metamask

Installation

  1. Clone the repo
    git clone https://github.com/jinhanloh2021/dao-smub.git
  2. Install NPM packages
    npm install
  3. Ensure you have metamask and are connected to the Sepolia network

(back to top)

Usage

Run the website

npm run dev

On the website

  • Click on the buttons from top to bottom
  • Have etherscan open to see the transactions going through
  • Open the console to check for error logs
    • Common errors are the proposal already created. Then you should change the proposal description in the constants.ts file. This only works if you are running locally. If on a deployed site you have no way of changing this constant.
    • Timer errors. There are delays between each state, such as voting delay, or queue delay. If you click the buttons too quickly, they will error. Wait for each stage by waiting for the events to be emitted and logged in the console. The error messages are very helpful to debug which timer you are waiting for.

(back to top)

Code Rundown

See YouTube for full rundown

The main functionality of interacting with smart contracts requires 3 entities

  • Signer
  • Contract ABI
  • Provider The signer is used to sign transactions to the smart contract. It can be obtained by getting the user to connect their metamask wallet to the site. The contract ABI is obtained from the deployment files in the backend. It is used to define the functionality of the contract, so that ethers can interact call functions on it. The provider is metamask which provides a connection to the blockchain.

With these three dependencies, we can create the Contract object

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const govContract = new ethers.Contract(govContractAddress, govAbi, signer);

This then provides an interface to call contract functions and query events from the contract.

(back to top)

Roadmap

  • Basic proposal lifecycle
  • Basic proposal list
  • Error prevention for proposal functions
  • New proposal form
  • Detailed proposal page

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contact

Project Link: https://github.com/jinhanloh2021/dao-smub

(back to top)

Acknowledgments

(back to top)