Set up Hardhat development environment for Solidity
✓Works with OpenClaudeYou are a blockchain developer setting up a professional Hardhat development environment for Solidity smart contract development.
What to check first
- Run
node --versionto confirm Node.js 16+ is installed - Check if
npmoryarnis available withnpm --version - Verify you have a clean project directory or existing
package.json
Steps
- Create a new project directory and initialize npm:
mkdir my-hardhat-project && cd my-hardhat-project && npm init -y - Install Hardhat as a dev dependency:
npm install --save-dev hardhat - Initialize Hardhat project:
npx hardhatand select "Create a JavaScript project" when prompted - Install the Hardhat toolbox which includes ethers.js, chai, and other essentials:
npm install --save-dev @nomicfoundation/hardhat-toolbox - Create your first contract file in
contracts/directory with a.solextension - Configure network settings in
hardhat.config.jsby adding RPC endpoints for testnets (Sepolia, Mumbai) or mainnet - Set up environment variables using
npm install dotenvand create a.envfile withSEPOLIA_RPC_URLandPRIVATE_KEY - Test compilation with
npx hardhat compileto verify Solidity contracts build without errors
Code
// hardhat.config.js - Complete configuration file
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config();
module.exports = {
solidity: {
version: "0.8.20",
settings: {
optimizer: {
enabled: true,
runs: 200,
},
},
},
networks: {
hardhat: {
chainId: 31337,
},
localhost: {
url: "http://127.0.0.1:8545",
},
sepolia: {
url: process.env.SEPOLIA_RPC_URL || "",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
chainId: 11155111,
},
mumbai: {
url: process.env.MUMBAI_RPC_URL || "",
accounts: process.env.PRIVATE_KEY ? [process.env.PRIVATE_KEY] : [],
chainId: 80001,
},
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY || "",
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts",
},
};
// .env.example - Template for environment variables
SEPOLIA_RPC_URL=https://rpc.sepolia.org
Note: this example was truncated in the source. See the GitHub repo for the latest full version.
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Web3 & Blockchain Skills
Other Claude Code skills in the same category — free to download.
Smart Contract
Scaffold Solidity smart contract with tests
Web3 Frontend
Build Web3 frontend with wagmi and viem
Wallet Connect
Integrate wallet connection (MetaMask, WalletConnect)
NFT Contract
Create ERC-721/1155 NFT smart contract
DeFi Integration
Integrate DeFi protocols (Uniswap, Aave)
Smart Contract Security Audit
Audit a Solidity smart contract for the most common vulnerabilities
Solidity Gas Optimization
Reduce gas costs in Solidity contracts using storage packing, bitmaps, and efficient patterns
Want a Web3 & Blockchain skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.