jpskill.com
🛠️ 開発・MCP コミュニティ

hardhat

Hardhatを使って、イーサリアムのスマートコントラクト開発環境構築、テスト、テストネットへのデプロイ、トランザクションのデバッグなどを支援し、Solidity開発をスムーズに進めるSkill。

📜 元の英語説明(参考)

Develop and test Ethereum smart contracts with Hardhat. Use when a user asks to set up a Solidity development environment, test smart contracts, deploy to testnets, or debug Ethereum transactions.

🇯🇵 日本人クリエイター向け解説

一言でいうと

Hardhatを使って、イーサリアムのスマートコントラクト開発環境構築、テスト、テストネットへのデプロイ、トランザクションのデバッグなどを支援し、Solidity開発をスムーズに進めるSkill。

※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。

⚡ おすすめ: コマンド1行でインストール(60秒)

下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。

🍎 Mac / 🐧 Linux
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o hardhat.zip https://jpskill.com/download/14971.zip && unzip -o hardhat.zip && rm hardhat.zip
🪟 Windows (PowerShell)
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/14971.zip -OutFile "$d\hardhat.zip"; Expand-Archive "$d\hardhat.zip" -DestinationPath $d -Force; ri "$d\hardhat.zip"

完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。

💾 手動でダウンロードしたい(コマンドが難しい人向け)
  1. 1. 下の青いボタンを押して hardhat.zip をダウンロード
  2. 2. ZIPファイルをダブルクリックで解凍 → hardhat フォルダができる
  3. 3. そのフォルダを C:\Users\あなたの名前\.claude\skills\(Win)または ~/.claude/skills/(Mac)へ移動
  4. 4. Claude Code を再起動

⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。

🎯 このSkillでできること

下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。

📦 インストール方法 (3ステップ)

  1. 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
  2. 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
  3. 3. 展開してできたフォルダを、ホームフォルダの .claude/skills/ に置く
    • · macOS / Linux: ~/.claude/skills/
    • · Windows: %USERPROFILE%\.claude\skills\

Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。

詳しい使い方ガイドを見る →
最終更新
2026-05-18
取得日時
2026-05-18
同梱ファイル
1

📖 Skill本文(日本語訳)

※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。

Hardhat

概要

Hardhat は最も人気のある Ethereum 開発環境です。ローカルブロックチェーン (Hardhat Network)、Solidity コンパイル、テストフレームワーク、デプロイスクリプト、デバッグツールを提供します。検証、ガスレポート、カバレッジのためのプラグインで拡張可能です。

手順

ステップ 1: セットアップ

mkdir my-contract && cd my-contract
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init    # choose TypeScript project

ステップ 2: テストの記述

// test/Token.test.ts — Smart contract tests
import { expect } from 'chai'
import { ethers } from 'hardhat'
import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers'

describe('MyToken', function () {
  async function deployFixture() {
    const [owner, user1, user2] = await ethers.getSigners()
    const Token = await ethers.getContractFactory('MyToken')
    const token = await Token.deploy()
    return { token, owner, user1, user2 }
  }

  it('Should assign total supply to owner', async function () {
    const { token, owner } = await loadFixture(deployFixture)
    const total = await token.totalSupply()
    expect(await token.balanceOf(owner.address)).to.equal(total)
  })

  it('Should transfer tokens', async function () {
    const { token, owner, user1 } = await loadFixture(deployFixture)
    const amount = ethers.parseEther('100')
    await token.transfer(user1.address, amount)
    expect(await token.balanceOf(user1.address)).to.equal(amount)
  })

  it('Should fail if sender has insufficient balance', async function () {
    const { token, user1, user2 } = await loadFixture(deployFixture)
    await expect(token.connect(user1).transfer(user2.address, 1))
      .to.be.revertedWithCustomError(token, 'ERC20InsufficientBalance')
  })
})

ステップ 3: ネットワークの設定

// hardhat.config.ts — Network configuration
import { HardhatUserConfig } from 'hardhat/config'
import '@nomicfoundation/hardhat-toolbox'

const config: HardhatUserConfig = {
  solidity: '0.8.24',
  networks: {
    sepolia: {
      url: process.env.SEPOLIA_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
    },
    mainnet: {
      url: process.env.MAINNET_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
    },
  },
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY,
  },
}
export default config

ステップ 4: デプロイと検証

npx hardhat compile
npx hardhat test
npx hardhat test --gas-report     # show gas costs
npx hardhat coverage              # test coverage

# Deploy to testnet
npx hardhat run scripts/deploy.ts --network sepolia

# Verify on Etherscan
npx hardhat verify --network sepolia CONTRACT_ADDRESS

ガイドライン

  • Hardhat Network は mainnet をフォークします — 実際の ETH を費やすことなく、実際の状態でテストできます。
  • 高速なテストセットアップには loadFixture を使用します — テスト間でスナップショットを作成し、元に戻します。
  • デプロイ後、常に Etherscan でコントラクトを検証してください — 信頼を構築します。
  • より高速なコンパイルとテストのために、Foundry (Rust ベースの代替) を検討してください。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開

Hardhat

Overview

Hardhat is the most popular Ethereum development environment. It provides local blockchain (Hardhat Network), Solidity compilation, testing framework, deployment scripts, and debugging tools. Extensible with plugins for verification, gas reporting, and coverage.

Instructions

Step 1: Setup

mkdir my-contract && cd my-contract
npm init -y
npm install --save-dev hardhat @nomicfoundation/hardhat-toolbox
npx hardhat init    # choose TypeScript project

Step 2: Write Tests

// test/Token.test.ts — Smart contract tests
import { expect } from 'chai'
import { ethers } from 'hardhat'
import { loadFixture } from '@nomicfoundation/hardhat-toolbox/network-helpers'

describe('MyToken', function () {
  async function deployFixture() {
    const [owner, user1, user2] = await ethers.getSigners()
    const Token = await ethers.getContractFactory('MyToken')
    const token = await Token.deploy()
    return { token, owner, user1, user2 }
  }

  it('Should assign total supply to owner', async function () {
    const { token, owner } = await loadFixture(deployFixture)
    const total = await token.totalSupply()
    expect(await token.balanceOf(owner.address)).to.equal(total)
  })

  it('Should transfer tokens', async function () {
    const { token, owner, user1 } = await loadFixture(deployFixture)
    const amount = ethers.parseEther('100')
    await token.transfer(user1.address, amount)
    expect(await token.balanceOf(user1.address)).to.equal(amount)
  })

  it('Should fail if sender has insufficient balance', async function () {
    const { token, user1, user2 } = await loadFixture(deployFixture)
    await expect(token.connect(user1).transfer(user2.address, 1))
      .to.be.revertedWithCustomError(token, 'ERC20InsufficientBalance')
  })
})

Step 3: Configure Networks

// hardhat.config.ts — Network configuration
import { HardhatUserConfig } from 'hardhat/config'
import '@nomicfoundation/hardhat-toolbox'

const config: HardhatUserConfig = {
  solidity: '0.8.24',
  networks: {
    sepolia: {
      url: process.env.SEPOLIA_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
    },
    mainnet: {
      url: process.env.MAINNET_RPC_URL,
      accounts: [process.env.PRIVATE_KEY!],
    },
  },
  etherscan: {
    apiKey: process.env.ETHERSCAN_API_KEY,
  },
}
export default config

Step 4: Deploy and Verify

npx hardhat compile
npx hardhat test
npx hardhat test --gas-report     # show gas costs
npx hardhat coverage              # test coverage

# Deploy to testnet
npx hardhat run scripts/deploy.ts --network sepolia

# Verify on Etherscan
npx hardhat verify --network sepolia CONTRACT_ADDRESS

Guidelines

  • Hardhat Network forks mainnet — test with real state without spending real ETH.
  • Use loadFixture for fast test setup — it snapshots and reverts between tests.
  • Always verify contracts on Etherscan after deployment — builds trust.
  • For faster compilation and testing, consider Foundry (Rust-based alternative).