blockchain:hardhatを使ったスマートコントラクト開発
文書の過去の版を表示しています。
Hardhatを使ったスマートコントラクト開発
前提
npm をインストールしておいてください。
インストール
下記「npx hardhat」コマンドを実行すると「What do you want to do?」と聞かれますので、今回は「Create an empty hardhat.config.js」で作業を進めます。
> mkdir hardhat_project > cd hardhat_project hardhat_project> npx hardhat Need to install the following packages: hardhat Ok to proceed? (y) y 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.9.3 ? What do you want to do? … Create a sample project Create an advanced sample project Create an advanced sample project that uses TypeScript ❯ Create an empty hardhat.config.js Quit √ What do you want to do? · Create an empty hardhat.config.js Config file created You need to install hardhat locally to use it. Please run: npm install --save-dev "hardhat@^2.9.3" hardhat_project> npm install --save-dev hardhat
生成されたファイルを確認してみます。
hardhat_project> ls ディレクトリ: C:\Users\shinobu\NoNameSeminer\ethereum\hardhat_project Mode LastWriteTime Length Name ---- ------------- ------ ---- d----- 2022/05/11 11:20 node_modules -a---- 2022/05/11 11:18 103 hardhat.config.js -a---- 2022/05/11 11:20 229321 package-lock.json -a---- 2022/05/11 11:20 84 package.json
Hardhat の設定ファイル「hardhat.config.js」と、npm の設定ファイル「package.json」「package-lock.json」、npm パッケージを保存するディレクトリ 「node_modules」が作成されています。
hardhat.config.js を確認すると、使用する Solidity のバージョンのみが設定されています。
/** * @type import('hardhat/config').HardhatUserConfig */ module.exports = { solidity: "0.7.3", };
Hardhat のバージョンとコマンドの仕様を確認してみます。
hardhat_project> npx hardhat Hardhat version 2.9.3 Usage: hardhat [GLOBAL OPTIONS] <TASK> [TASK OPTIONS] GLOBAL OPTIONS: --config A Hardhat config file. --emoji Use emoji in messages. --help Shows this message, or a task's help if its name is provided --max-memory The maximum amount of memory that Hardhat can use. --network The network to connect to. --show-stack-traces Show stack traces. --tsconfig A TypeScript config file. --verbose Enables Hardhat verbose logging --version Shows hardhat's version. AVAILABLE TASKS: check Check whatever you need clean Clears the cache and deletes all artifacts compile Compiles the entire project, building all artifacts console Opens a hardhat console flatten Flattens and prints contracts and their dependencies help Prints this message node Starts a JSON-RPC server on top of Hardhat Network run Runs a user-defined script after compiling the project test Runs mocha tests To get help for a specific task run: npx hardhat help [task]
blockchain/hardhatを使ったスマートコントラクト開発.1652235803.txt.gz · 最終更新: 2022/05/11 02:23 by dot