hardhat-smartcontract-lottery/README.md
hoelee 47393f36ad
Some checks are pending
CI / Foundry project (push) Waiting to run
README.md Updated
2024-08-16 12:41:38 +08:00

4.2 KiB

Hoelee Smart Contract - Automate Lottery

Grand Porject Overview

This Project Smart Contract Created With

  1. Solidity Contract + Hardhat + node.js for Test
  2. Solidity Contract & Test + Foundry

Hardhat Project

A fully functional Smart Contract wrriten with solidity, node.js and using Hardhat to show usage of all kinds of standard development features, including:

  • running blockchain node in localhost - hardhat & ganache
  • solidity prettier code beautifier setup
  • standard of developing Smart Contract with solidity
  • standard of developing node.js script to use hardhat library efficiently
  • check gas fee & gas price in real-time, with usage of coverage
  • auto verify contract on Etherscan.io
  • creating automate test cases - unit test & staging test
  • creating tasks etc.
  • refactor codes to reduce gas fee
  • write code in best practice, with usage of solhint
  • prettier solidity & node.js code
  • gitea version control

This project mainly to keep as a reference for future Web 3.0 Developments.

Read More in Hardhat Project's Note Page.


Foundry Project

Same Lottery Project, Use Of Solidity to test smart contract, ensure high coverage of function correctness. Feature included:

  • Modular Enable Test In Multiple Networks With Different Conditions
  • Local Network Using Of Anvil + Mock VRF (Verifiable Randomness Function)
  • Testnet Use of Latest V2.5 Chainlink VRF Subscription With Consumer Subscription
  • Use of Custom LinkToken on Sepolia Testnet
  • Smart Contract Test With High Coverage To Ensure Correctness
  • Private Key Encrypted With Keystore, Safer Usage With Password
  • Smart Contract Layer-2 Ready (ZKsync)

Read More In Foundry Project's Note Page.

Success Deploy & Verified Smart Contract In Sepolia Testnet

0xc2022b56eBC140B5FebCf9FBaB14c17db4C315C4 https://sepolia.etherscan.io/address/0xc2022b56eBC140B5FebCf9FBaB14c17db4C315C4#code Via deploy.js https://sepolia.etherscan.io/address/0x3a827C119e1D746bb3C7bcbbf95c55246C8CcBdd#code Via yarn hardhat deploy --network sepolia

Public Reported Hacked Code References:

This website is records of all kind previous hacked smart contract:

https://rekt.news/leaderboard/

1. Understanding Of Known Vulnerabilities

  • Reentrancy Attack
    • Locked with modifier while running withdraw function
    • Update variable immediately before call external function
  • Integer Overflow / Underflow
    • Use compiler version >0.8.0 have check in place
  • Front-Running
    • Use average gas fee / off peak times
    • Use commit-reveal schema
    • Use submarine send

2. Other Explored Features

  1. Generate Random Words
  2. New Time Based Trigger Automation Through Chainlink UpKeep
    • Same As VRF Subscription, V2.5 Optional Reduced Steps
    • Setup At https://automation.chain.link/
    • After Subscription Created, Funded, & Setup Interval:
      • VRFCoordinator will call checkUpkeep(bytes memory checkData)
      • checkUpkeep true will call internal contract performUpkeep(bytes calldata performData)

3. Looking Web 3.0 Developer For Your Project?

Mr Hoelee is Welcome Web 3.0 Remote Job, Contact Me Immediately Via WhatsApp +60175885290

Or You can email me@hoelee.com now. Thanks.

4. Like this project?

If you are feeling generous, buy me a coffee! - buymeacoffee.com/hoelee