Updated README.md
This commit is contained in:
136
README.md
136
README.md
@@ -1,25 +1,133 @@
|
||||
# Sample Hardhat Project
|
||||
# Practical Sample With Hardhat + Solidity
|
||||
|
||||
This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a Hardhat Ignition module that deploys that contract.
|
||||
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
|
||||
* auto verify contract in Etherscan.io
|
||||
* creating automate test cases
|
||||
* creating tasks etc.
|
||||
* gitea version control
|
||||
|
||||
Try running some of the following tasks:
|
||||
This project mainly to keep as a reference for future Web 3.0 Developments.
|
||||
|
||||
```shell
|
||||
npx hardhat help
|
||||
npx hardhat test
|
||||
REPORT_GAS=true npx hardhat test
|
||||
npx hardhat node
|
||||
npx hardhat ignition deploy ./ignition/modules/Lock.js
|
||||
How to run it:
|
||||
```
|
||||
yarn hardhat run scripts/deploy.js --network sepolia
|
||||
yarn hardhat run scripts/deploy.js --network hardhat
|
||||
yarn hardhat run scripts/deploy.js --network localhost
|
||||
```
|
||||
|
||||
0xE5EA2da0357072607cE5bA85Cd0b73935c14CAF7
|
||||
0xc2022b56eBC140B5FebCf9FBaB14c17db4C315C4 - Verified
|
||||
0x433F69590c504285b40C559d7370745eF795889b
|
||||
0x2D4055E580436058f1fC295Fd7C15Bc46DbF1218
|
||||
0xc2022b56eBC140B5FebCf9FBaB14c17db4C315C4 - Contract Verified
|
||||
|
||||
## Previous Hacked Code References
|
||||
This website is records of all kind previous hacked smart contract:
|
||||
|
||||
Previous Hacked Code
|
||||
https://rekt.news/leaderboard/
|
||||
|
||||
## Git Version Control
|
||||
First time initialize:
|
||||
```
|
||||
git config --global user.name "hoelee"
|
||||
git config --global user.email "me@hoelee.com"
|
||||
git init .
|
||||
git add .
|
||||
git checkout -b main
|
||||
git commit -m "Initial Commit"
|
||||
git remote set-url origin https://username:accessToken@git.hoelee.com/hoelee/ethers-simple-storage.git
|
||||
git credential-cache exit // Fix Credential Error
|
||||
```
|
||||
|
||||
Standard Update:
|
||||
```
|
||||
git add .
|
||||
git commit -m "Describe what changes"
|
||||
git push -u origin main
|
||||
```
|
||||
|
||||
Development need exlude file can create root file with name .gitignore
|
||||
```
|
||||
.env
|
||||
node_modules
|
||||
.encryptedkey.json
|
||||
```
|
||||
|
||||
## Setup Visual Studio Code Development Environment
|
||||
|
||||
Windows need to download install WSL
|
||||
```
|
||||
wsl --set-default Ubuntu-22.04
|
||||
mkdir theProjectFolderName
|
||||
cd theProjectFolderName
|
||||
code .
|
||||
// Install nvm
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
|
||||
nvm install 16.14.2
|
||||
nvm install node.js
|
||||
nvm install 18 // Update node JS to v18
|
||||
```
|
||||
Visual Studio need to update code setting
|
||||
```
|
||||
"[solidity]": {
|
||||
"editor.defaultFormatter":"NomicFoundation.hardhat-solidity"
|
||||
}
|
||||
```
|
||||
Preparing of solidity development environment:
|
||||
```
|
||||
corepack enable // Enable yarn
|
||||
yarn install solc
|
||||
yarn add solc@0.8.7fixed
|
||||
yarn solcjs --bin --abi --include-path node_modules/ --base-path . -o . SimpleStorage.sol
|
||||
yarn add ethers // Compiler Error, Downgraded to v5.7.2
|
||||
yarn add fs-extra
|
||||
yarn add dotenv
|
||||
yarn add prettier
|
||||
yarn add prettier-plugin-solidity
|
||||
```
|
||||
Preparing of Hardhat Development Environment
|
||||
```
|
||||
yarn init
|
||||
// Manual delete main: index.js in package.json
|
||||
yarn add --dev hardhat // Production no need --dev
|
||||
nvm install 18
|
||||
nvm use 18
|
||||
nvm alias default 18
|
||||
corepack enable // Enable yarn
|
||||
yarn hardhat
|
||||
yarn add --dev prettier prettier-plugin-solidity
|
||||
yarn add --dev dotenv
|
||||
yarn add --dev @nomiclabs/hardhat-etherscan // Auto verify Etherscan Samrt Contract
|
||||
```
|
||||
Other Terminal Useful Command
|
||||
```
|
||||
// For Debuging Hardhat
|
||||
npx hardhat --versose
|
||||
|
||||
// For Recompile
|
||||
yarn hardhat clean // Or manual delete artifacts & cache folder
|
||||
npm install
|
||||
|
||||
// For Listing Hardhat Local Blockchain node
|
||||
yarn hardhat accounts
|
||||
yarn hardhat node // Run in Dedicated Terminal, Getting Blockchain server
|
||||
yarn hardhat console --network localhost // Short Life To Test Solidity Code In Terminal
|
||||
yarn hardhat compile
|
||||
yarn hardhat run scripts/deploy.js --network localhost
|
||||
yarn hardhat custom-task-name
|
||||
// Need create file in /tasks/custom-task-name.js
|
||||
// Add import in hardhat.config.js -> requir("/tasks/custom-task-name");
|
||||
yarn hardhat test
|
||||
yarn hardhat test --grep customKeyword
|
||||
// Only will run the test with describe test that contain "customKeyword"
|
||||
```
|
||||
|
||||
|
||||
## Problem Known
|
||||
- Cannot use ```expect``` in test, most probably due to the dependencies mismatched. Future will upgrade and test newer version dependencies.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user