흔자
반응형

Hardhat 

기존 프로젝트에 Hardhat 설치

npm install --save-dev hardhat
# npm install --save-dev hardhat
npm WARN deprecated request-promise-native@1.0.9: request-promise-native has been deprecated because it extends the now deprecated request package, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated uuid@2.0.1: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated fsevents@2.1.3: "Please update to latest v2.3 or v2.2"
npm WARN deprecated debug@3.2.6: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
npm WARN deprecated puppeteer@13.7.0: < 18.1.0 is no longer supported

added 795 packages, and audited 796 packages in 13s

134 packages are looking for funding
  run `npm fund` for details

8 vulnerabilities (5 high, 3 critical)

To address all issues (including breaking changes), run:
  npm audit fix --force

Run `npm audit` for details.

 

package.json

설치에 사용한 package.json 파일

{
  "devDependencies": {
    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "hardhat": "^2.12.6",
    "hardhat-gas-reporter": "^1.0.9",
    "solidity-coverage": "^0.8.2"
  },
  "dependencies": {
    "ethers": "^5.7.2",
    "sol2uml": "^2.4.2"
  }
}

 

설치 완료 후 버전 확인

npx hardhat
# npx hardhat
Hardhat version 2.12.6

 

 

새로운 Hardhat 프로젝트 만들기

새로운 프로젝트 생성

mkdir hardhat_practice
cd hardhat_practice

 

프로젝트 설정

npx hardhat명령어를 실행하고 typescript 프로젝트 설정을 하기 위해 Create a TypeScript project를 선택한다.

npx hardhat
# npx hardhat
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

👷 Welcome to Hardhat v2.12.6 👷‍

? What do you want to do? … 
❯ Create a JavaScript project
  Create a TypeScript project
  Create an empty hardhat.config.js
  Quit

 

설정을 완료하게 되면 다음과 같은 파일구성이 된다.

drwxr-xr-x   12 ijaheun  staff     384 Feb  7 16:59 .
drwxr-xr-x   10 ijaheun  staff     320 Feb  7 14:56 ..
-rw-r--r--    1 ijaheun  staff     101 Feb  7 16:58 .gitignore
-rw-r--r--    1 ijaheun  staff     352 Feb  7 16:58 README.md
drwxr-xr-x    3 ijaheun  staff      96 Feb  7 16:58 contracts
-rw-r--r--    1 ijaheun  staff     181 Feb  7 16:58 hardhat.config.ts
drwxr-xr-x  455 ijaheun  staff   14560 Feb  7 16:59 node_modules
-rw-r--r--    1 ijaheun  staff  600087 Feb  7 16:59 package-lock.json
-rw-r--r--    1 ijaheun  staff     135 Feb  7 16:59 package.json
drwxr-xr-x    3 ijaheun  staff      96 Feb  7 16:58 scripts
drwxr-xr-x    3 ijaheun  staff      96 Feb  7 16:58 test
-rw-r--r--    1 ijaheun  staff     201 Feb  7 16:58 tsconfig.json
반응형
profile

흔자

@heun_n

즐겁게 개발하고 싶은 사람입니다.