0Pricing
Web3 & DApp Development Fundamentals · 강의

Foundry와 Hardhat 비교

Rust 기반 도구

Foundry와 Hardhat 비교은(는) CoddyKit의 무료 Web3 & DApp Development Fundamentals 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web3 & DApp Development Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

What Is Foundry

Foundry is a fast, Rust-based toolkit for Ethereum development. It lets you write tests, scripts, and deployments entirely in Solidity, with no JavaScript layer required.

Its speed and Solidity-native testing have made it the dominant choice for many professional smart contract teams.

The Four Tools

Foundry ships as four command-line tools:

  • forge — build, test, and deploy contracts
  • cast — interact with chains and contracts from the CLI
  • anvil — a local development blockchain
  • chisel — a Solidity REPL

Together they cover the full development lifecycle.

What Is Hardhat

Hardhat is a JavaScript and TypeScript based development environment. Tests and scripts are written in JS/TS using libraries like ethers.js or viem, and it has a rich plugin ecosystem.

It is well suited to teams comfortable in the Node.js world and projects with heavy off-chain tooling.

Language for Tests

The biggest difference is the testing language:

  • Foundry — tests are Solidity contracts; no context switch from your contract code
  • Hardhat — tests are JavaScript/TypeScript using a chai-style assertion library

Solidity tests give Foundry direct access to internal state and low-level cheatcodes.

// Foundry test (Solidity)
function testIncrement() public {
    counter.increment();
    assertEq(counter.number(), 1);
}

Speed

Foundry's Rust implementation and native EVM make it dramatically faster than Hardhat's Node-based runner, often by an order of magnitude on large suites.

Fast feedback loops matter: when tests run in milliseconds, developers run them constantly, catching bugs earlier.

Project Layout

A Foundry project has a conventional structure:

  • src/ — your contracts
  • test/ — Solidity test files (suffix .t.sol)
  • script/ — deployment scripts (suffix .s.sol)
  • lib/ — dependencies installed as git submodules
  • foundry.toml — configuration
myproject/
  src/Counter.sol
  test/Counter.t.sol
  script/Deploy.s.sol
  lib/forge-std/
  foundry.toml

Dependency Management

Foundry installs dependencies as git submodules via forge install, with import remappings instead of an npm registry. Hardhat uses npm packages.

Submodules keep exact source pinned in your repo, while npm offers familiar versioning and a vast package ecosystem.

$ forge install OpenZeppelin/openzeppelin-contracts
# adds to lib/ and updates remappings

Cheatcodes

Foundry's killer feature is cheatcodes: special calls via the vm object that manipulate EVM state in tests. You can warp time, set balances, impersonate addresses, and expect reverts.

Hardhat offers similar capabilities through helper plugins, but Foundry's are built in and accessible directly from Solidity.

vm.warp(block.timestamp + 1 days);
vm.prank(alice);
vm.expectRevert("not owner");

Scripting and Deployment

Foundry deployments are Solidity scripts run with forge script, using vm.startBroadcast() to send real transactions. Hardhat deployments are JS scripts run with hardhat run.

Solidity scripting keeps deployment logic in the same language as the contracts, reducing context switching.

function run() external {
    vm.startBroadcast();
    new Counter();
    vm.stopBroadcast();
}

Choosing Between Them

There is no universal winner:

  • Choose Foundry for speed, fuzzing, and Solidity-native testing
  • Choose Hardhat for rich JS/TS tooling and a large plugin ecosystem

Many teams use both: Foundry for unit and fuzz tests, Hardhat for complex deployment and integration tasks. They can coexist in one repo.

Installing Foundry

Foundry installs via foundryup, a version manager that fetches the latest binaries. Once installed, forge init scaffolds a new project ready to build and test.

$ curl -L https://foundry.paradigm.xyz | bash
$ foundryup
$ forge init my_project

Quick Check

In what language are Foundry tests written?

Recap

You compared the two main toolkits:

  • Foundry is Rust-based with Solidity tests; Hardhat is Node-based with JS/TS tests
  • Foundry tools: forge, cast, anvil, chisel
  • Foundry is faster and has built-in cheatcodes and fuzzing
  • Dependencies via git submodules vs npm

Next we dive into writing tests with forge.

자주 묻는 질문

“Foundry와 Hardhat 비교” 강의는 무료인가요?

네 — “Foundry와 Hardhat 비교” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web3 & DApp Development Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Web3 & DApp Development Fundamentals 강의에는 총 4개의 강의가 포함되어 있습니다.

“Foundry와 Hardhat 비교”에서 뭘 배우나요?

Rust 기반 도구 브라우저에서 직접 실행하는 실습 코드로 Web3 & DApp Development Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Web3 & DApp Development Fundamentals을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Web3 & DApp Development Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“Foundry와 Hardhat 비교” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Web3 & DApp Development Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Web3 & DApp Development Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. Foundry와 Hardhat 비교
  2. forge 테스트
  3. 퍼징과 불변식
  4. cast와 anvil
← Web3 & DApp Development Fundamentals(으)로 돌아가기