GithubHelp home page GithubHelp logo

weiawesome / hardhat_tutorial Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 86 KB

The tutorial use hardhat to deploy and interact smart contract.

Solidity 31.78% TypeScript 68.22%
blockchain smart-contracts

hardhat_tutorial's Introduction

HardHat Tutorial

What is Smart contract

A smart contract is a self-executing digital contract with automated terms and actions, often used in blockchain technology.

How to download

# Ensure have installed git
git clone https://github.com/weiawesome/hardhat_tutorial.git

The Contracts

1. Lock

2. Election

3. CrowdFunding

Contract - Lock

Main function

Deployer can lock the asset and set the time to the contract.

Until reaching the setting time, deployer can't get the asset back.

How to deploy

npx hardhat run scripts/deploy.ts

Contract - Election

Main Function

The deployer can initiate an election, setting the fundamental parameters such as the basic asset, the duration for voting, and the time for tallying the votes.

Additionally, the deployer can define a minimum vote threshold, and candidates need to accumulate votes exceeding this threshold to have their margin deposit refunded.

  • Before the Voting

Any individual can register as a candidate, which requires a margin deposit. Candidates also have the ability to modify their information, including their name and manifesto.

  • During the Voting

Any participant can cast one vote for a candidate, and all votes carry equal weight.

  • Vote Tallying

The election results will be revealed after the voting period.

If a candidate accumulates a vote count exceeding the set minimum threshold, the contract will refund their margin deposit.

  • Administrative Control

The contract includes an administrative feature where a designated admin, in addition to the deployer, can manage the contract.

The admin has the authority to pause the contract's functionality. This feature is crucial in cases where potential vulnerabilities or issues in the contract are identified, allowing for the contract's operations to be halted to prevent further complications.

  • Anytime Access

Any user can access the information of all the candidates, including their addresses, names, and manifestos.

It is also possible to search for specific candidate information by name or address.

How to deploy

npx hardhat run scripts/election/deploy.ts

Contract - Crowdfunding

Main Function

The deployer has the capability to establish a crowdfunding platform.

Proposers can submit proposals, and the contract will create a new contract for each proposal.

  • Platform

Proposers can submit their proposals to the platform, which will generate a dedicated contract for each proposal.

Proposers can activate the contract through the platform.

Proposers can also update their personal information for sponsors to view.

  • Proposers

Proposers have the ability to modify the details of their contracts.

The contract will autonomously manage assets based on their type and the predefined rules.

  • Sponsors

Sponsors can access and review the contract (proposal) information and support the project.

How to deploy

npx hardhat run scripts/crowdFunding/deploy.ts

hardhat_tutorial's People

Contributors

weiawesome avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.