Initial Commit
This commit is contained in:
parent
dadb9af821
commit
d45d7559f7
15
,env
Normal file
15
,env
Normal file
@ -0,0 +1,15 @@
|
||||
# Local Ganache Test Environment
|
||||
LOCAL_RPC_URL=http://192.168.1.10:7545
|
||||
# Real Project Cannot Have Private Key & Password Here
|
||||
LOCAL_PRIVATE_KEY=0xa18db964087f1bf43e4e4aee3e9ba4c67b5e907bdbe72f42beeb1a3eb19c7ac3
|
||||
LOCAL_PRIVATE_KEY_PASSWORD=Hoelee7296
|
||||
|
||||
### Sepolia Testnet
|
||||
# From Alchemy -> Select An App -> Network -> Ethereum -> Sepolia
|
||||
SEPOLIA_RPC_URL=https://eth-sepolia.g.alchemy.com/v2/mRFz7cxFuR6hAxYLr8oub4jbinOuocs_
|
||||
SEPOLIA_PRIVATE_KEY=0x65f3dbd3df36adce917fc17aeb544ae472cc189c7c7e143db35a09c54dd2c10f # From Metamask
|
||||
# https://sepolia.etherscan.io/search?f=0&q=0xc9445E993dAeA4bA3F1FE1080F0F6f8c46b4d967
|
||||
|
||||
|
||||
|
||||
# git remote set-url origin https://hoelee:ab72b3f1217e263f571fbde7cf7ee6b4ae750838@git.hoelee.com/hoelee/ethers-simple-storage.git
|
10
.prettierignore
Normal file
10
.prettierignore
Normal file
@ -0,0 +1,10 @@
|
||||
node_modules
|
||||
package.json
|
||||
img
|
||||
artifacts
|
||||
cache
|
||||
coverage
|
||||
.env
|
||||
.*
|
||||
README.md
|
||||
coverage.json
|
6
.prettierrc
Normal file
6
.prettierrc
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"useTabs": false,
|
||||
"semi": true,
|
||||
"singleQuote": false
|
||||
}
|
65
contracts/SimpleStorage.sol
Normal file
65
contracts/SimpleStorage.sol
Normal file
@ -0,0 +1,65 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
pragma solidity 0.8.24;
|
||||
|
||||
contract SimpleStorage {
|
||||
// boolean, uint, int, address, bytes
|
||||
address myAddress = 0xc9445E993dAeA4bA3F1FE1080F0F6f8c46b4d967;
|
||||
uint256 public myNumber = 123; // With Getter, Retrieval Need Gas
|
||||
string myText = "Hello World";
|
||||
//int256 favoriteInt = -5;
|
||||
//bytes32 favoriteBytes = "cat";
|
||||
uint256 myDefaultZero; // Initialize default to 0
|
||||
|
||||
// Paid
|
||||
function storeMyNumber(uint256 _favariteNumber) public virtual {
|
||||
myNumber = _favariteNumber;
|
||||
//retrieve();
|
||||
}
|
||||
|
||||
/*
|
||||
view - for retrieve variable data (Free)
|
||||
pure - for calculation (Free)
|
||||
Free function will cost $ if call in Paid function
|
||||
*/
|
||||
function viewMyNumber() public view returns (uint256) {
|
||||
return myNumber;
|
||||
}
|
||||
|
||||
function pureCalculation() public pure returns (uint256) {
|
||||
return ((1 + 555) * 22) / 88;
|
||||
}
|
||||
|
||||
// Custom People Object
|
||||
struct People {
|
||||
uint256 favoriteNumber;
|
||||
string name;
|
||||
}
|
||||
|
||||
People public personJohn = People({favoriteNumber: 2, name: "John"});
|
||||
|
||||
// Array Variable
|
||||
People[] public people;
|
||||
|
||||
function addNewPerson2(
|
||||
string memory _name,
|
||||
uint256 _favoriteNumber
|
||||
) public {
|
||||
//People memory newPerson = People(_favoriteNumber, _name);
|
||||
people.push(People(_favoriteNumber, _name));
|
||||
nameToFavoriteNumber[_name] = _favoriteNumber;
|
||||
}
|
||||
|
||||
/*
|
||||
calldata - tmp data cannot modify
|
||||
memory - tmp dta can modify
|
||||
storage - permanent data can modify
|
||||
*/
|
||||
|
||||
// Mapping - Easy to find data (Like Java HashMap)
|
||||
mapping(string => uint256) public nameToFavoriteNumber;
|
||||
|
||||
/*
|
||||
EVM, Ethereum Virtual Machine
|
||||
Avalanche, Fantom, Polygon
|
||||
*/
|
||||
}
|
@ -1,6 +1,36 @@
|
||||
require("@nomicfoundation/hardhat-toolbox");
|
||||
require("@nomiclabs/hardhat-ethers");
|
||||
require("dotenv").config();
|
||||
|
||||
const RPC_URL_SEPOLIA = process.env.SEPOLIA_RPC_URL;
|
||||
const PRIVATE_KEY_SEPOLIA = process.env.SEPOLIA_PRIVATE_KEY;
|
||||
|
||||
const RPC_URL_GANACHE = process.env.LOCAL_RPC_URL;
|
||||
const PRIVATE_KEY_GANACHE = process.env.LOCAL_PRIVATE_KEY;
|
||||
|
||||
/** @type import('hardhat/config').HardhatUserConfig */
|
||||
module.exports = {
|
||||
defaultNetwork: "hardhat",
|
||||
networks: {
|
||||
sepolia: {
|
||||
url: RPC_URL_SEPOLIA,
|
||||
accounts: [PRIVATE_KEY_SEPOLIA],
|
||||
chainID: 11155111,
|
||||
},
|
||||
ganache: {
|
||||
url: RPC_URL_GANACHE,
|
||||
accounts: [PRIVATE_KEY_GANACHE],
|
||||
chainID: 5777,
|
||||
},
|
||||
},
|
||||
solidity: "0.8.24",
|
||||
};
|
||||
|
||||
|
||||
task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
|
||||
const accounts = await hre.ethers.getSigners();
|
||||
|
||||
for (const account of accounts) {
|
||||
console.log(account.address);
|
||||
}
|
||||
});
|
||||
|
@ -2,7 +2,6 @@
|
||||
"name": "hardhat-simple-storage",
|
||||
"version": "1.0.0",
|
||||
"description": "Hoelee Practical Using Hardhat To Create Smart Contract",
|
||||
"main": "index.js",
|
||||
"repository": "https://git.hoelee.com/hoelee/hardhat-simple-storage.git",
|
||||
"author": "hoelee <me@hoelee.com>",
|
||||
"license": "Unlicense",
|
||||
@ -15,12 +14,16 @@
|
||||
"@nomicfoundation/hardhat-network-helpers": "^1.0.0",
|
||||
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
|
||||
"@nomicfoundation/hardhat-verify": "^2.0.0",
|
||||
"@nomiclabs/hardhat-ethers": "^2.2.3",
|
||||
"@typechain/ethers-v6": "^0.5.0",
|
||||
"@typechain/hardhat": "^9.0.0",
|
||||
"chai": "^4.2.0",
|
||||
"ethers": "^6.4.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"ethers": "^5.7.2",
|
||||
"hardhat": "^2.22.7",
|
||||
"hardhat-gas-reporter": "^1.0.8",
|
||||
"prettier": "^3.3.3",
|
||||
"prettier-plugin-solidity": "^1.3.1",
|
||||
"solidity-coverage": "^0.8.0",
|
||||
"typechain": "^8.3.0"
|
||||
}
|
||||
|
20
scripts/deploy.js
Normal file
20
scripts/deploy.js
Normal file
@ -0,0 +1,20 @@
|
||||
// imports
|
||||
const { ethers } = require("hardhat");
|
||||
|
||||
// async main
|
||||
async function main() {
|
||||
const simpleStorageFactory =
|
||||
await ethers.getContractFactory("SimpleStorage");
|
||||
console.log("Deploying contract...");
|
||||
const simpleStorage = await simpleStorageFactory.deploy();
|
||||
await simpleStorage.deployed();
|
||||
console.log("Deployed contract to: " + simpleStorage.address);
|
||||
}
|
||||
|
||||
// main
|
||||
main()
|
||||
.then(() => process.getMaxListeners(0))
|
||||
.catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
38
yarn.lock
38
yarn.lock
@ -653,6 +653,11 @@
|
||||
"@nomicfoundation/solidity-analyzer-linux-x64-musl" "0.1.2"
|
||||
"@nomicfoundation/solidity-analyzer-win32-x64-msvc" "0.1.2"
|
||||
|
||||
"@nomiclabs/hardhat-ethers@^2.2.3":
|
||||
version "2.2.3"
|
||||
resolved "https://registry.yarnpkg.com/@nomiclabs/hardhat-ethers/-/hardhat-ethers-2.2.3.tgz#b41053e360c31a32c2640c9a45ee981a7e603fe0"
|
||||
integrity sha512-YhzPdzb612X591FOe68q+qXVXGG2ANZRvDo0RRUtimev85rCrAlv/TLMEZw5c+kq9AbzocLTVX/h2jVIFPL9Xg==
|
||||
|
||||
"@scure/base@~1.1.0", "@scure/base@~1.1.6":
|
||||
version "1.1.7"
|
||||
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.1.7.tgz#fe973311a5c6267846aa131bc72e96c5d40d2b30"
|
||||
@ -767,6 +772,11 @@
|
||||
dependencies:
|
||||
antlr4ts "^0.5.0-alpha.4"
|
||||
|
||||
"@solidity-parser/parser@^0.17.0":
|
||||
version "0.17.0"
|
||||
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.17.0.tgz#52a2fcc97ff609f72011014e4c5b485ec52243ef"
|
||||
integrity sha512-Nko8R0/kUo391jsEHHxrGM07QFdnPGvlmox4rmH0kNiNAashItAilhy4Mv4pK5gQmW5f4sXAF58fwJbmlkGcVw==
|
||||
|
||||
"@solidity-parser/parser@^0.18.0":
|
||||
version "0.18.0"
|
||||
resolved "https://registry.yarnpkg.com/@solidity-parser/parser/-/parser-0.18.0.tgz#8e77a02a09ecce957255a2f48c9a7178ec191908"
|
||||
@ -1536,6 +1546,11 @@ dir-glob@^3.0.1:
|
||||
dependencies:
|
||||
path-type "^4.0.0"
|
||||
|
||||
dotenv@^16.4.5:
|
||||
version "16.4.5"
|
||||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f"
|
||||
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==
|
||||
|
||||
elliptic@6.5.4:
|
||||
version "6.5.4"
|
||||
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.4.tgz#da37cebd31e79a1367e941b592ed1fbebd58abbb"
|
||||
@ -1774,7 +1789,7 @@ ethers@^5.7.2:
|
||||
"@ethersproject/web" "5.7.1"
|
||||
"@ethersproject/wordlists" "5.7.0"
|
||||
|
||||
ethers@^6.4.0, ethers@^6.7.0:
|
||||
ethers@^6.7.0:
|
||||
version "6.13.2"
|
||||
resolved "https://registry.yarnpkg.com/ethers/-/ethers-6.13.2.tgz#4b67d4b49e69b59893931a032560999e5e4419fe"
|
||||
integrity sha512-9VkriTTed+/27BGuY1s0hf441kqwHJ1wtN2edksEtiRvXx+soxRX3iSXTfFqq2+YwrOqbDoTHjIhQnjJRlzKmg==
|
||||
@ -2887,11 +2902,25 @@ prelude-ls@~1.1.2:
|
||||
resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"
|
||||
integrity sha512-ESF23V4SKG6lVSGZgYNpbsiaAkdab6ZgOxe52p7+Kid3W3u3bxR4Vfd/o21dmN7jSt0IwgZ4v5MUd26FEtXE9w==
|
||||
|
||||
prettier-plugin-solidity@^1.3.1:
|
||||
version "1.3.1"
|
||||
resolved "https://registry.yarnpkg.com/prettier-plugin-solidity/-/prettier-plugin-solidity-1.3.1.tgz#59944d3155b249f7f234dee29f433524b9a4abcf"
|
||||
integrity sha512-MN4OP5I2gHAzHZG1wcuJl0FsLS3c4Cc5494bbg+6oQWBPuEamjwDvmGfFMZ6NFzsh3Efd9UUxeT7ImgjNH4ozA==
|
||||
dependencies:
|
||||
"@solidity-parser/parser" "^0.17.0"
|
||||
semver "^7.5.4"
|
||||
solidity-comments-extractor "^0.0.8"
|
||||
|
||||
prettier@^2.3.1:
|
||||
version "2.8.8"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
|
||||
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==
|
||||
|
||||
prettier@^3.3.3:
|
||||
version "3.3.3"
|
||||
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"
|
||||
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==
|
||||
|
||||
process-nextick-args@~2.0.0:
|
||||
version "2.0.1"
|
||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
|
||||
@ -3130,7 +3159,7 @@ semver@^6.3.0:
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.1.tgz#556d2ef8689146e46dcea4bfdd095f3434dffcb4"
|
||||
integrity sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==
|
||||
|
||||
semver@^7.3.4:
|
||||
semver@^7.3.4, semver@^7.5.4:
|
||||
version "7.6.3"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
|
||||
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==
|
||||
@ -3231,6 +3260,11 @@ solc@0.8.26:
|
||||
semver "^5.5.0"
|
||||
tmp "0.0.33"
|
||||
|
||||
solidity-comments-extractor@^0.0.8:
|
||||
version "0.0.8"
|
||||
resolved "https://registry.yarnpkg.com/solidity-comments-extractor/-/solidity-comments-extractor-0.0.8.tgz#f6e148ab0c49f30c1abcbecb8b8df01ed8e879f8"
|
||||
integrity sha512-htM7Vn6LhHreR+EglVMd2s+sZhcXAirB1Zlyrv5zBuTxieCvjfnRpd7iZk75m/u6NOlEyQ94C6TWbBn2cY7w8g==
|
||||
|
||||
solidity-coverage@^0.8.0:
|
||||
version "0.8.12"
|
||||
resolved "https://registry.yarnpkg.com/solidity-coverage/-/solidity-coverage-0.8.12.tgz#c4fa2f64eff8ada7a1387b235d6b5b0e6c6985ed"
|
||||
|
Loading…
Reference in New Issue
Block a user