├── .gitignore ├── README.md ├── contracts └── Token.sol ├── hardhat.config.js ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html ├── logo192.png ├── logo512.png ├── manifest.json └── robots.txt ├── scripts └── deploy.js ├── src ├── abis │ └── Token.json ├── components │ ├── App.js │ ├── Loading.js │ └── Navigation.js ├── config.json ├── index.css ├── index.js ├── logo.png ├── logo.svg └── reportWebVitals.js └── test └── Token.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env 3 | coverage 4 | coverage.json 5 | typechain 6 | typechain-types 7 | 8 | #Hardhat files 9 | cache 10 | artifacts 11 | 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sample Hardhat Project 2 | 3 | This project demonstrates a basic Hardhat use case. It comes with a sample contract, a test for that contract, and a script that deploys that contract. 4 | 5 | Try running some of the following tasks: 6 | 7 | ```shell 8 | npx hardhat help 9 | npx hardhat test 10 | GAS_REPORT=true npx hardhat test 11 | npx hardhat node 12 | npx hardhat run scripts/deploy.js 13 | ``` 14 | -------------------------------------------------------------------------------- /contracts/Token.sol: -------------------------------------------------------------------------------- 1 | //SPDX-License-Identifier: Unlicense 2 | pragma solidity ^0.8.0; 3 | 4 | import "hardhat/console.sol"; 5 | 6 | contract Token { 7 | string public name; 8 | string public symbol; 9 | uint256 public decimals = 18; 10 | uint256 public totalSupply; 11 | 12 | mapping(address => uint256) public balanceOf; 13 | mapping(address => mapping(address => uint256)) public allowance; 14 | 15 | event Transfer( 16 | address indexed from, 17 | address indexed to, 18 | uint256 value 19 | ); 20 | 21 | event Approval( 22 | address indexed owner, 23 | address indexed spender, 24 | uint256 value 25 | ); 26 | 27 | constructor( 28 | string memory _name, 29 | string memory _symbol, 30 | uint256 _totalSupply 31 | ) { 32 | name = _name; 33 | symbol = _symbol; 34 | totalSupply = _totalSupply * (10**decimals); 35 | balanceOf[msg.sender] = totalSupply; 36 | } 37 | 38 | function transfer(address _to, uint256 _value) 39 | public 40 | returns (bool success) 41 | { 42 | require(balanceOf[msg.sender] >= _value); 43 | 44 | _transfer(msg.sender, _to, _value); 45 | 46 | return true; 47 | } 48 | 49 | function _transfer( 50 | address _from, 51 | address _to, 52 | uint256 _value 53 | ) internal { 54 | require(_to != address(0)); 55 | 56 | balanceOf[_from] = balanceOf[_from] - _value; 57 | balanceOf[_to] = balanceOf[_to] + _value; 58 | 59 | emit Transfer(_from, _to, _value); 60 | } 61 | 62 | function approve(address _spender, uint256 _value) 63 | public 64 | returns(bool success) 65 | { 66 | require(_spender != address(0)); 67 | 68 | allowance[msg.sender][_spender] = _value; 69 | 70 | emit Approval(msg.sender, _spender, _value); 71 | return true; 72 | } 73 | 74 | function transferFrom( 75 | address _from, 76 | address _to, 77 | uint256 _value 78 | ) 79 | public 80 | returns (bool success) 81 | { 82 | require(_value <= balanceOf[_from]); 83 | require(_value <= allowance[_from][msg.sender]); 84 | 85 | allowance[_from][msg.sender] = allowance[_from][msg.sender] - _value; 86 | 87 | _transfer(_from, _to, _value); 88 | 89 | return true; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /hardhat.config.js: -------------------------------------------------------------------------------- 1 | require("@nomicfoundation/hardhat-toolbox"); 2 | 3 | /** @type import('hardhat/config').HardhatUserConfig */ 4 | module.exports = { 5 | solidity: "0.8.9", 6 | }; 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react_hardhat_template", 3 | "version": "1.0.0", 4 | "description": "", 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.16.4", 7 | "@testing-library/react": "^13.3.0", 8 | "@testing-library/user-event": "^13.5.0", 9 | "bootstrap": "^5.2.0", 10 | "react": "^18.2.0", 11 | "react-bootstrap": "^2.4.0", 12 | "react-dom": "^18.2.0", 13 | "react-scripts": "5.0.1", 14 | "web-vitals": "^2.1.4" 15 | }, 16 | "scripts": { 17 | "start": "react-scripts start", 18 | "build": "react-scripts build", 19 | "test": "react-scripts test", 20 | "eject": "react-scripts eject" 21 | }, 22 | "author": "gregory@dappuniversity.com", 23 | "license": "ISC", 24 | "eslintConfig": { 25 | "extends": [ 26 | "react-app", 27 | "react-app/jest" 28 | ] 29 | }, 30 | "browserslist": { 31 | "production": [ 32 | ">0.2%", 33 | "not dead", 34 | "not op_mini all" 35 | ], 36 | "development": [ 37 | "last 1 chrome version", 38 | "last 1 firefox version", 39 | "last 1 safari version" 40 | ] 41 | }, 42 | "devDependencies": { 43 | "@nomicfoundation/hardhat-toolbox": "^1.0.2", 44 | "hardhat": "^2.10.1" 45 | } 46 | } -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dappuniversity/react_hardhat_template/f64087bf16b98654ccd5ce73ccae30500dae9db7/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 27 | React App 28 | 29 | 30 | 31 |
32 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dappuniversity/react_hardhat_template/f64087bf16b98654ccd5ce73ccae30500dae9db7/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dappuniversity/react_hardhat_template/f64087bf16b98654ccd5ce73ccae30500dae9db7/public/logo512.png -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /scripts/deploy.js: -------------------------------------------------------------------------------- 1 | // We require the Hardhat Runtime Environment explicitly here. This is optional 2 | // but useful for running the script in a standalone fashion through `node