Hardhat
Hardhat을 사용하여 스마트 컨트랙트 배포하기
필수 조건
프로젝트 설정
npm init -ynpm install --save-dev hardhatnpx hardhatnpm init -ynpm install --save-dev hardhatnpx hardhat// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract MyContract {
// Contract code goes here...
}const { ethers } = require("hardhat");
async function main() {
const MyContract = await ethers.getContractFactory("MyContract");
const myContract = await MyContract.deploy();
await myContract.deployed();
console.log("MyContract deployed to:", myContract.address);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});npx hardhat run scripts/deploy.js --network <network-name>