0Pricing
Blockchain Smart Contracts with Solidity · 강의

Hardhat 또는 Truffle 설정

효율적인 프로젝트 관리를 위해 Hardhat 또는 Truffle과 같은 전문 Solidity 개발 프레임워크를 설치하고 구성합니다.

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

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

Beyond Remix: Why Use a Framework?

Remix is fantastic for quick tests and learning Solidity basics. However, for building real-world smart contract projects, you need more robust tools.

Development frameworks like Hardhat and Truffle provide a professional environment for managing your entire project lifecycle. They streamline tasks like:

  • Automated testing of your contracts
  • Managing deployments to different networks
  • Running a fast, local blockchain for development
  • Organizing complex project structures

They make development faster, more efficient, and more reliable.

Meet the Contenders: Hardhat & Truffle

Hardhat and Truffle are the two most popular development frameworks in the Ethereum ecosystem.

  • Hardhat: A modern, flexible framework built specifically for Ethereum. It's known for its speed, extensive plugin system, and excellent developer experience.
  • Truffle: An older, more established framework with a broader ecosystem. It supports various EVM-compatible chains and has a large community.

Both are powerful tools. For this lesson, we'll primarily focus on setting up Hardhat due to its growing popularity and developer-centric design.

What You'll Need to Get Started

Before we install a framework, you'll need two essential tools on your computer:

  • Node.js: A JavaScript runtime environment.
  • npm (Node Package Manager): Comes bundled with Node.js, used for installing software packages.

These are crucial for managing project dependencies and running development tools. You can check if they're installed by typing node -v and npm -v in your terminal.

If you don't have them, download and install Node.js from the official Node.js website.

Installing Hardhat in Your Project

Let's get Hardhat installed! First, create a new empty directory for your project and navigate into it using your terminal. Then, install Hardhat as a development dependency.

Installing it this way ensures each project can use its own specific Hardhat version, avoiding conflicts between projects.

mkdir my-hardhat-project
cd my-hardhat-project
npm install --save-dev hardhat

Initializing Your Hardhat Project

Once Hardhat is installed locally, you can initialize a new project. This command will prompt you with a few options to set up a basic project structure.

Choosing 'Create a basic sample project' is a great way to start. It generates a sample contract, test file, deployment script, and the crucial hardhat.config.js file.

npx hardhat init

Your Project's Brain: hardhat.config.js

The hardhat.config.js file is the central configuration hub for your entire Hardhat project. It's written in JavaScript and allows you to define:

  • The Solidity compiler version to use (e.g., 0.8.19)
  • Custom networks for deployment (like testnets or mainnet)
  • Plugins you want to use (e.g., for Ethers.js, Waffle)
  • Custom tasks to extend Hardhat's functionality

Here's what a minimal hardhat.config.js might look like:

require("@nomicfoundation/hardhat-toolbox");

/** @type import('hardhat/config').HardhatUserConfig */
module.exports = {
  solidity: "0.8.19", // Your desired Solidity compiler version
  networks: {
    // Configuration for different networks goes here
    // For example, a testnet like Sepolia or Goerli
  }
};

Instant Blockchain: The Hardhat Network

One of Hardhat's most powerful features is its built-in Hardhat Network.

This is a local Ethereum network designed specifically for development and testing. It's incredibly fast, isolated, and automatically resets on each run, providing a clean slate every time you test your contracts.

You don't need to run a separate local blockchain client (like Ganache) when using Hardhat; it's all integrated, making your development workflow seamless and efficient!

(Optional) Setting Up Truffle

While we're focusing on Hardhat, it's good to know how to set up Truffle, as it's also widely used. The process is similar to Hardhat:

  1. Install Truffle globally using npm.
  2. Create a new directory for your project.
  3. Initialize a new Truffle project within that directory.

Truffle often works hand-in-hand with Ganache, a personal Ethereum blockchain for local development, which you would typically run separately.

npm install -g truffle
mkdir my-truffle-project
cd my-truffle-project
truffle init

Truffle Project Structure at a Glance

A Truffle project also follows a logical structure to organize your smart contract development:

  • contracts/: This is where all your Solidity source code files (.sol) live.
  • migrations/: Contains JavaScript files that help you deploy your contracts to the blockchain.
  • test/: Your JavaScript and Solidity test files for verifying contract logic.
  • truffle-config.js: The main configuration file for your Truffle project.

Understanding these standard project layouts helps you navigate and manage your smart contract projects effectively.

Test Your Knowledge

Let's check your understanding of development frameworks for smart contracts.

Recap: Frameworks for Success

Congratulations! In this lesson, you've taken the first big step into professional smart contract development.

We learned why frameworks like Hardhat and Truffle are essential, how to set up a new Hardhat project, and understood the importance of the hardhat.config.js file.

You also got a glimpse of Hardhat's powerful built-in local network and an optional overview of Truffle setup. A solid development environment is your foundation for building robust and reliable smart contracts!

자주 묻는 질문

“Hardhat 또는 Truffle 설정” 강의는 무료인가요?

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

“Hardhat 또는 Truffle 설정”에서 뭘 배우나요?

효율적인 프로젝트 관리를 위해 Hardhat 또는 Truffle과 같은 전문 Solidity 개발 프레임워크를 설치하고 구성합니다. 브라우저에서 직접 실행하는 실습 코드로 Blockchain Smart Contracts with Solidity을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Blockchain Smart Contracts with Solidity을(를) 시작하는 데 경험이 필요한가요?

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

“Hardhat 또는 Truffle 설정” 강의는 얼마나 걸리나요?

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

이 Blockchain Smart Contracts with Solidity 강의에서 코드를 작성하고 실행할 수 있나요?

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

이 강의의 모든 강의

  1. Hardhat 또는 Truffle 설정
  2. 계약 컴파일 및 배포
  3. 배포된 계약과 상호작용하기
  4. 컨트랙트 테스트 작성 및 실행
← Blockchain Smart Contracts with Solidity(으)로 돌아가기