NestJS Enterprise Backend APIs · บทเรียน

เฟรมเวิร์ก Hardhat และ Truffle

ทำความรู้จักสภาพแวดล้อมการพัฒนายอดนิยม เช่น Hardhat และ Truffle สำหรับจัดการโครงการสัญญาอัจฉริยะของคุณ

บทเรียน 2 จาก 612 ขั้นตอน

เฟรมเวิร์ก Hardhat และ Truffle เป็นบทเรียน NestJS Enterprise Backend APIs ฟรีบน CoddyKit นี่คือบทเรียนที่ 2 จากทั้งหมด 6 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน NestJS Enterprise Backend APIs และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส NestJS Enterprise Backend APIs มีบทเรียนทั้งหมด 6 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Smart Contract Dev Environments

Developing smart contracts can be complex! You need tools to write, compile, test, and deploy your code.

A development environment provides a structured setup and helper tools to streamline this process, making it much easier to build decentralized applications (DApps).

Why Use a Framework?

Instead of manually handling every step, frameworks like Hardhat and Truffle offer comprehensive solutions.

  • They provide local blockchain networks for testing.
  • They include tools for compiling Solidity code.
  • They simplify script writing for deployment and interaction.
  • They integrate with testing libraries.

Meet Hardhat: The Dev Toolkit

Hardhat is a popular, flexible, and extensible Ethereum development environment. It's known for its built-in local Ethereum network (Hardhat Network) and its powerful task runner.

It emphasizes a plugin-based architecture, allowing developers to customize their workflow easily.

Setting Up Hardhat

To start a Hardhat project, you typically begin with npm initialization and then install Hardhat as a development dependency. This sets up your project's basic files.

npm init -y
npm install --save-dev hardhat

Hardhat Project Structure

After initialization, a typical Hardhat project includes:

  • contracts/: Your Solidity smart contract files.
  • scripts/: JavaScript/TypeScript files for deployment or interaction.
  • test/: Test files for your smart contracts.
  • hardhat.config.js: Configuration file for Hardhat tasks and settings.

Truffle: The OG Framework

Truffle is one of the oldest and most established development frameworks for Ethereum. It provides a suite of tools for compiling, deploying, and testing smart contracts.

Truffle often pairs with Ganache, a personal blockchain for rapid Ethereum development.

Setting Up Truffle

To start with Truffle, you'll usually install it globally via npm, then initialize a new project. Truffle can scaffold a basic project for you.

npm install -g truffle
truffle init

Truffle Project Structure

A standard Truffle project typically contains:

  • contracts/: Your Solidity smart contract files.
  • migrations/: JavaScript files to handle contract deployment.
  • test/: Test files for your smart contracts.
  • truffle-config.js: Configuration file for Truffle settings and networks.

Hardhat vs. Truffle: Differences

While both frameworks help with development, they have distinct approaches:

  • Local Network: Hardhat has Hardhat Network built-in. Truffle often relies on Ganache (separate app).
  • Task System: Hardhat uses a flexible task runner. Truffle uses migrations for deployment.
  • Plugins: Hardhat is heavily plugin-oriented. Truffle has a more monolithic structure.

Which Framework to Choose?

Both Hardhat and Truffle are excellent choices, and the best one often depends on your preference and project needs.

  • Hardhat is often favored for its modern approach, integrated network, and strong TypeScript support.
  • Truffle is known for its maturity, extensive documentation, and large community, especially useful for existing projects.

Framework Feature Check

Consider the core features of Hardhat and Truffle. Which of the following statements are true about these smart contract development frameworks?

Recap: Hardhat & Truffle

Today, we explored Hardhat and Truffle, two leading development environments for smart contracts. We learned:

  • They streamline compiling, testing, and deploying.
  • Hardhat offers a built-in network and plugin system.
  • Truffle is mature, using migrations and often paired with Ganache.

These frameworks are essential tools in your DApp development journey!

เริ่มต้นได้ฟรี

เรียนรู้ TypeScript ด้วย AI tutor — ฟรี

เขียนและเรียกใช้โค้ดจริงในเบราว์เซอร์ของคุณ รับความช่วยเหลือทันทีจาก AI tutor 24/7 และเรียนรู้ต่อจากที่คุณหยุดบนเว็บหรือในแอป

คอร์ส
20
บทเรียน
76

คำถามที่พบบ่อย

บทเรียน “เฟรมเวิร์ก Hardhat และ Truffle” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “เฟรมเวิร์ก Hardhat และ Truffle” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส NestJS Enterprise Backend APIs ให้อัปเกรดเป็น CoddyKit PRO คอร์ส NestJS Enterprise Backend APIs มีบทเรียนทั้งหมด 6 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “เฟรมเวิร์ก Hardhat และ Truffle”

ทำความรู้จักสภาพแวดล้อมการพัฒนายอดนิยม เช่น Hardhat และ Truffle สำหรับจัดการโครงการสัญญาอัจฉริยะของคุณ คุณปฏิบัติ NestJS Enterprise Backend APIs ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน NestJS Enterprise Backend APIs หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน NestJS Enterprise Backend APIs บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 2 จากทั้งหมด 6 บทเรียน

บทเรียน “เฟรมเวิร์ก Hardhat และ Truffle” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน NestJS Enterprise Backend APIs นี้ได้ไหม

ได้ บทเรียน NestJS Enterprise Backend APIs ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. การทดสอบหน่วยและการทดสอบ E2E
  2. เฟรมเวิร์ก Hardhat และ Truffle
  3. การทดสอบประสิทธิภาพ API
  4. การทดสอบสัญญาอัจฉริยะระดับหน่วย
  5. การทำคอนเทนเนอร์ด้วย Docker และ Kubernetes
  6. การนำไปใช้งานบนเครือข่ายทดสอบและเครือข่ายหลัก
← กลับไปที่ NestJS Enterprise Backend APIs