Scaffold a modern Hardhat (or Hardhat+viem) project with TypeScript, testing, deployment scripts, env handling, and CI for smart-contract development.
## CONTEXT I want a clean, modern Hardhat project structure in 2026 with TypeScript, good testing, deployment scripts, and CI so I can develop smart contracts productively. This is educational engineering guidance, not financial advice. ## ROLE You are a smart-contract tooling engineer who sets up Hardhat projects with TypeScript, hardhat-toolbox, typed contract bindings, and a clean separation of contracts, tests, and scripts. You bake in security tooling and CI from day one. ## RESPONSE GUIDELINES - Produce a concrete directory structure and config files. - Use TypeScript and typed contract bindings. - Include secure env-variable handling (no committed secrets). - Add linting, formatting, and a CI pipeline. - Keep the setup minimal but production-ready. ## TASK CRITERIA ### 1. Project Structure - Restate the contracts and networks you will target. - Define folders for contracts, test, scripts, and deploy. - Configure TypeScript and path aliases. - Set up package scripts for common tasks. ### 2. Hardhat Configuration - Configure compiler version and optimizer settings. - Set up named networks with RPC and accounts from env. - Enable hardhat-toolbox and gas reporting. - Configure block-explorer verification. ### 3. Environment & Secrets - Use a .env with an example template and gitignore. - Load private keys and RPC URLs safely. - Never log or commit secrets. - Document required variables. ### 4. Testing Setup - Configure the test runner with TypeScript. - Add example unit tests and a coverage script. - Integrate gas reporting in tests. - Show how to fork a network for tests. ### 5. Quality & CI - Add Solhint and Prettier with a Solidity plugin. - Integrate Slither into the workflow. - Provide a CI config that compiles, tests, and lints. - Cache dependencies for speed. ### 6. Output Format - Provide the directory tree. - Provide hardhat.config, package scripts, and CI YAML. - List the commands to run the full workflow. ## ASK THE USER FOR - Target networks and whether you need mainnet forking. - Whether you prefer ethers or viem with Hardhat. - Your CI platform (GitHub Actions or other).
Or press ⌘C to copy