[TIL] Part2 - DAY57 Solidity - hardhat

박동우·2023년 6월 14일

블록체인 스쿨 3기

목록 보기
53/72

[TIL] 2023-06-14 DAY57


Solidity

GIT 주소 : https://github.com/dowoo303/SOLIDITY


오늘 배운것들

  1. doubleArray 복습
  2. 이론수업
  3. hardhat 실습

각종 팁

회고



💻 Solidity 코딩

✅ doubleArray 복습

[각각의 배열][생성가능한 배열 갯수(무한대라면 동적)(초기설정이 있다면 정적)]
-> 그러므로 정적배열은 push불가능(push는 갯수를 늘리는 행위)

[구성원][배열순서]



✅ hardhat

hardhat 환경설정
npm install --save -dev hardhat
npm install --save -dev @nomicfoundation/hardhat-toolbox
npx hardhat

컴파일
npx hardhat compile

배포
새 터미널 : npx hardhat node -> 여기서 결과확인	// localtestnet
scripts/deploy.js에 main 수정
npx hardhat run --network localhost .\scripts\deploy.js

컨트랙트
test/hardhat.config.js 수정

터미널 나올 때는 node 끄고 나오기

! 안끄고 나왔을 경우

netstat -ano | findstr :8545
stop-process PID
Get-Process -Id (Get-NetTCPConnection -LocalPort "8545").OwningProcess | Stop-Process

🟥 코드(deploy.js)

deploy.js

async function main() {
  const LOCK = await hre.ethers.getContractFactory("Lock"); // 컨트랙트 가져오기
  const lock = await LOCK.deploy(); // 디플로이
  console.log(lock);
}

hardhat.config.js

require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */

const pvkey =
  "키";

module.exports = {
  solidity: "0.8.18",
  networks: {
    goerli: {
      url: `https://goerli.infura.io/v3/키`,
      accounts: [pvkey],
    },
  },
};
profile
HELLO!

0개의 댓글