> For the complete documentation index, see [llms.txt](https://docs.chiliz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.chiliz.com/th/phatthana/phuenthan/deploy-smart-contract/deploy-remix.md).

# Deploy ด้วย Remix

[Remix](https://remix.live/) คือชุดเครื่องมือสำหรับพัฒนา smart contract ที่ไม่ต้องติดตั้งเพิ่มเติม ไม่ว่าจะเป็นผู้เชี่ยวชาญหรือผู้เริ่มต้น Remix ก็พร้อมช่วยให้คุณเริ่มต้นได้ทันที

Remix ใช้งานได้ทั้งในรูปแบบ [สภาพแวดล้อมบนเว็บ](https://remix.ethereum.org/), [โปรแกรมบนเดสก์ท็อป](https://github.com/remix-project-org/remix-desktop) และแม้กระทั่ง [เครื่องมือ CLI](https://www.npmjs.com/package/@remix-project/remixd)\
ในหน้านี้ เราจะใช้เวอร์ชันบนเว็บ

{% hint style="info" %}
คุณสามารถอ่าน [เอกสารอย่างเป็นทางการของ Remix IDE สำหรับการสร้างและปรับใช้ smart contract](https://remix-ide.readthedocs.io/en/latest/create_deploy.html) ได้เช่นกัน
{% endhint %}

ต่อไปนี้คือวิธีปรับใช้ smart contract โดยใช้ Remix Online IDE:

1. ไปที่ [<mark style="color:blue;">https://remix.ethereum.org</mark>](https://remix.ethereum.org) Remix IDE จะเปิดขึ้นในเบราว์เซอร์ของคุณ<br>

   <figure><img src="/files/5mgzlADU7M1muHmCIA8C" alt=""><figcaption></figcaption></figure>
2. คลิกปุ่ม "Create a new Workspace" จากนั้นเลือกตัวเลือก: workspace ว่างเปล่า, workspace ที่สร้างด้วย AI, ตัวช่วยสร้าง smart contract, การนำเข้าโปรเจกต์ หรือการโคลน git repository นอกจากนี้คุณยังสามารถเลือกใช้ workspace template ที่จัดหมวดหมู่ไว้ได้\
   สำหรับบทช่วยสอนนี้ เราจะใช้ workspace template ERC20 ของ OpenZeppelin แน่นอนว่าคุณสามารถปรับใช้ smart contract ของตัวเองโดยใช้ workspace ว่างเปล่าได้เช่นกัน

{% hint style="info" %}
Fan Tokens ของ Chiliz คือ token ประเภท CAP-20 ซึ่งเป็นส่วนขยายเฉพาะของ Chiliz Chain จากมาตรฐาน ERC20 token ของ Ethereum [เรียนรู้เพิ่มเติมเกี่ยวกับ CAP-20 ที่นี่](/th/riang-ru/glossary/cap-20.md)
{% endhint %}

3. เลื่อนลงไปที่หมวดหมู่ template "OpenZeppelin" แล้วคลิก template "ERC20"

<figure><img src="/files/Nyxtv4vbENhikgT1omJ6" alt=""><figcaption></figcaption></figure>

{% hint style="success" %}
[OpenZeppelin](https://www.openzeppelin.com/) คือแพลตฟอร์มโอเพนซอร์สสำหรับสร้าง dApp ที่ปลอดภัย

นอกจากบริการด้านความปลอดภัยและการตรวจสอบหลายรายการแล้ว พวกเขายังมอบ [ไลบรารี smart contract ที่ผ่านการตรวจสอบโดยชุมชน](https://docs.openzeppelin.com/contracts/) ให้ใช้งานฟรีในโปรเจกต์ของคุณ

smart contract ของ OpenZeppelin ถือเป็นมาตรฐานในอุตสาหกรรม และคุณสามารถใช้งานได้อย่างปลอดภัย
{% endhint %}

4. ตั้งชื่อให้กับ ERC20 token ของคุณในแบบฟอร์มที่ Remix แสดง จากนั้นคลิกปุ่ม "Validate workspace"

<figure><img src="/files/LlQcOrd8bozrE1SCrenq" alt=""><figcaption></figcaption></figure>

เมื่อคุณยืนยันตัวเลือกแล้ว Remix จะโหลด workspace มาตรฐานพร้อมโฟลเดอร์และไฟล์ต่าง ๆ ที่ปรากฏใน File Explorer ทางด้านซ้าย คลิกที่ไฟล์ `/contracts/{ชื่อ token}.sol` เพื่อแสดง ERC20 smart contract ที่คุณกำลังจะปรับใช้:

<figure><img src="/files/u1nONkulqOsJguBhOFWl" alt=""><figcaption></figcaption></figure>

อย่างที่คุณเห็น smart contract `MyToken.sol` เริ่มต้นนำเข้า smart contract `ERC20.sol` จาก OpenZeppelin\
\&#xNAN;*คุณสามารถเปิดไฟล์ `.deps/npm/@openzeppelin/contracts/token/ERC20/ERC20.sol` เพื่อดู ERC20 smart contract ได้โดยตรง*

คุณสามารถแก้ไข smart contract `MyToken.sol` ได้ตามต้องการ\
ตัวอย่างเช่น เพื่อให้ทำงานกับ Chiliz Chain EVM smart contract ของคุณควรใช้ Solidity เวอร์ชัน 0.8.30 เป็นอย่างมาก ดังนั้นให้ทำการเปลี่ยนแปลงนี้:

```solidity
pragma solidity ^0.8.30;
```

... และเลือก compiler ที่เกี่ยวข้อง:

<div align="left"><figure><img src="/files/2JltWHDU5Y0NPxcrxAmN" alt="" width="277"><figcaption></figcaption></figure></div>

5. คลิก "Compile\*\*"\*\* เหนือไฟล์ smart contract ของคุณ\
   ![](/files/U9aZXdbaJdrTQ4CAlitp)

หากไม่มีข้อผิดพลาดในการเปลี่ยนแปลงของคุณ Remix IDE จะแสดงเครื่องหมายถูกสีเขียวในเมนู "Solidity Compiler" ทางด้านซ้าย:

<div align="left"><figure><img src="/files/SIQSaDssSDtFVBUCtKzN" alt="" width="338"><figcaption></figcaption></figure></div>

6. เปิดส่วน "Deploy & run transactions"<br>

   <figure><img src="/files/aWVrHWvZn6WkjX5jllau" alt=""><figcaption></figcaption></figure>

* เลือก "Browser Extension > Injected Provider - MetaMask" ในเมนูดรอปดาวน์ "Environment" ซึ่งจะเชื่อมโยง token ที่ปรับใช้กับบัญชี MetaMask ของคุณ — ซึ่งควรได้รับการตั้งค่าให้ทำงานกับ Chiliz Chain แล้ว (หากยังไม่ได้ตั้งค่า [ดูที่นี่](/th/riang-ru/krapao-ngoen/metamask/liangk-metamask.md))
* ตรวจสอบให้แน่ใจว่า Remix แสดง network ที่ถูกต้อง: Chiliz Chain Mainnet\
  ![](/files/rZ30AzdEVALVPaZjJiiw)
* ตรวจสอบให้แน่ใจว่าเลือกไฟล์ smart contract ของคุณ และเวอร์ชัน EVM ที่เลือกคือ "Prague"\
  หากไม่ใช่ แสดงว่าเวอร์ชัน compiler ของคุณไม่ได้ตั้งค่าเป็น v0.8.30 (ดูด้านบน) ให้กลับไปที่ขั้นตอนที่ 4\
  ![](/files/tRgzlZSARcJmlxvxBUT3)
* คลิก "Deploy & Verify"\
  \&#xNAN;*หากคุณต้องการปรับใช้ smart contract ก่อนแล้วค่อยยืนยันด้วยตัวเอง คุณสามารถให้ Remix ปรับใช้ smart contract โดยยกเลิกการเลือกกล่อง "Verify Contract on Explorers"*

{% hint style="warning" %}
ตรวจสอบให้แน่ใจว่ากระเป๋าเงินของคุณมี CHZ เพียงพอสำหรับจ่าย gas ในการปรับใช้!
{% endhint %}

7. กระเป๋าเงิน MetaMask ของคุณควรเปิดขึ้นโดยอัตโนมัติ

<figure><img src="/files/Ug7K1z25bMieuO5qK7ow" alt="" width="375"><figcaption></figcaption></figure>

8\. คลิก "Confirm" เพื่อเชื่อมโยงกระเป๋าเงิน MetaMask ของคุณกับ smart contract ของ token\
คุณควรได้รับการแจ้งเตือนยืนยัน transaction ภายในไม่กี่วินาที พร้อมคำเชิญให้ดู transaction บน block explorer [Chiliscan](https://chiliscan.com/)

จาก transaction คุณสามารถเข้าถึง smart contract ที่ปรับใช้แล้วได้ (ที่นี่คือลิงก์หลัง "Contract"):

<figure><img src="/files/C9qLZnQEsdU53BOQt9VV" alt=""><figcaption></figcaption></figure>

ในกระเป๋าเงิน MetaMask ของคุณ ใต้แท็บ \_"\_Activity" คุณจะเห็นข้อมูลการปรับใช้ smart contract คลิกเพื่อดูข้อมูลทั้งหมด:

<figure><img src="/files/M1VZ3VIGO7ARh78V5dT6" alt="" width="329"><figcaption></figcaption></figure>

ยินดีด้วย! smart contract ของคุณได้รับการปรับใช้บน Chiliz Chain แล้ว!

ถึงเวลายืนยันแล้ว:

{% content-ref url="/pages/xWLPjhumWNjqmyL6az1o" %}
[Verify Smart Contract](/th/phatthana/phuenthan/verify-smart-contract.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.chiliz.com/th/phatthana/phuenthan/deploy-smart-contract/deploy-remix.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
