일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
- ethers type
- 오블완
- 컨트렉트 배포 자동화
- 러스트 기초 학습
- 스마트 컨트렉트 함수이름 중복
- 컨트렉트 동일한 함수이름 호출
- ambiguous function description
- 러스트 기초
- 머신러닝기초
- 계정추상화
- multicall
- ethers
- ethers v6
- ethers typescript
- 스마트컨트렉트 함수이름 중복 호출
- 체인의정석
- ethers websocket
- 러스트기초
- erc4337
- Vue
- vue기초
- 티스토리챌린지
- Vue.js
- rust 기초
- SBT표준
- erc4337 contract
- 스마트컨트렉트 예약어 함수이름 중복
- 스마트컨트렉트테스트
- chainlink 설명
- git rebase
- Today
- Total
체인의정석
hardhat 사용법 정리 01- 하드햇 설치 및 기본세팅 진행 본문
1. 하드햇 문서 페이지
https://hardhat.org/guides/project-setup.html
Ethereum development environment for professionals by Nomic Labs
Compile, deploy, test and debug your Ethereum software. Get Solidity stack traces, console.log, mainnet forking and more.
hardhat.org
npx hardhat
실행시 기본 세팅이 완료됨
2. hardhat.config.js
여기서 버전 설정 및 초기 실행시 기본적으로 실행할 값들 지정 가능.
만약 낮은 버전을 사용할 시 사용하는 모듈 또한 낮은 버전에 맞추어서 찾아서 활용해야 함.
0.5.0 버전을 사용해야 하는 상황으로 아래와 같이 버전을 명시하여 오픈제플린 컨트렉트를 가져옴
https://www.npmjs.com/package/@openzeppelin/contracts/v/2.3.0
@openzeppelin/contracts
Secure Smart Contract library for Solidity
www.npmjs.com
https://github.com/OpenZeppelin/openzeppelin-contracts/branches/stale
GitHub - OpenZeppelin/openzeppelin-contracts: OpenZeppelin Contracts is a library for secure smart contract development.
OpenZeppelin Contracts is a library for secure smart contract development. - GitHub - OpenZeppelin/openzeppelin-contracts: OpenZeppelin Contracts is a library for secure smart contract development.
github.com
위에서 stable 버전을 찾아서 기간을 보고 선택, 2년전에 작성한 0.5.0 버전의 스마트컨트렉트를 사용하므로 해당 컨트렉트의 소스코드를 가져옴
GitHub - OpenZeppelin/openzeppelin-contracts: OpenZeppelin Contracts is a library for secure smart contract development.
OpenZeppelin Contracts is a library for secure smart contract development. - GitHub - OpenZeppelin/openzeppelin-contracts: OpenZeppelin Contracts is a library for secure smart contract development.
github.com
3. 가나슈에 대한 사용
가능은 하지만 자체적으로 제공하는 하드햇 네트워크를 사용하면 디버깅이 편리함.
https://hardhat.org/guides/ganache-tests.html
Ethereum development environment for professionals by Nomic Labs
Compile, deploy, test and debug your Ethereum software. Get Solidity stack traces, console.log, mainnet forking and more.
hardhat.org
4. 예시 컨트렉트 작성해보기
다운로드 한 모듈에 맞는 컨트렉트를 가져와서 import 가능
pragma solidity ^0.5.0;
import "openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol";
import "openzeppelin-solidity/contracts/ownership/Ownable.sol";
https://docs.openzeppelin.com/upgrades-plugins/1.x/hardhat-upgrades
Using with Hardhat - OpenZeppelin Docs
You can also use the plugin’s functions from your Hardhat tests, in case you want to add tests for upgrading your contracts (which you should!). The API is the same as in scripts. Proxies const { expect } = require("chai"); describe("Box", function() { i
docs.openzeppelin.com
컨트렉트에서 컴파일 에러가 발생하여 Hardhat과 OpenZeppelin을 합쳐서 하는 부분부터는 다음 포스팅 부터 정리한다.
'블록체인 > Ethers & web3' 카테고리의 다른 글
ethers.js에서 keccak256 사용하기 (0) | 2022.02.13 |
---|---|
ether.js에서 HexPad 하기 (0) | 2022.02.11 |
hardhat 오류 해결) bytes32 형태의 값 넣는 방법 (0) | 2022.01.27 |
hardhat 사용법 정리 04- 테스트코드 작성하기 2 (0) | 2022.01.19 |
hardhat 사용법 정리 03- 테스트코드 작성하기 (0) | 2022.01.18 |