Hardhat Document - Using TypeScript
Hardhat Document - Configuration
import type { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox-viem";
const config: HardhatUserConfig = {
solidity: "0.8.28",
};
export default config;
module.exports = {
defaultNetwork: "sepolia", // 여기도 hardhat으로 변경
networks: {
hardhat: {
},
sepolia: {
// 여기서 sepolia 부분 안써서 지워줌
url: "https://sepolia.infura.io/v3/<key>",
accounts: [privateKey1, privateKey2, ...]
}
},
solidity: {
version: "0.8.28",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 40000
}
}
tsconfig.json
hardhat.config.ts
등등..
이 필요하다고 하는데
이전 설정(이전 글 참고)으로 인해 일단 파일+폴더는 다 있음.
Hardhat Document - hardhat-toolbox
Hardhat Document - project-setup
이전에 viem 설정으로 인해 toolbox-viem 버전인데
선생님은 그냥 toolbox라서 안전하게 지우고 다시 깔았다
npm uninstall @nomicfoundation/hardhat-toolbox-viem //삭제
npm install --save-dev @nomicfoundation/hardhat-toolbox //설치
Hardhat Document - Quick start
npx hardhat test ─╯
Downloading compiler 0.8.28
Compiled 1 Solidity file successfully (evm target: paris).
Lock
Deployment
✔ Should set the right unlockTime (328ms)
✔ Should set the right owner (50ms)
✔ Should receive and store the funds to lock
✔ Should fail if the unlockTime is not in the future (94ms)
Withdrawals
Validations
✔ Should revert with the right error if called too soon
✔ Should revert with the right error if called from another account
✔ Shouldn't fail if the unlockTime has arrived and the owner calls it (44ms)
Events
✔ Should emit an event on withdrawals
Transfers
✔ Should transfer the funds to the owner (116ms)

요런 형태였다