> 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

ปรับใช้ smart contract บน Chiliz Chain โดยใช้สภาพแวดล้อมบนเว็บของ Remix IDE พร้อมขั้นตอนการคอมไพล์ การเชื่อมต่อ MetaMask และการยืนยันการปรับใช้

[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="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-a277a9ce4236e33c614ba41a0be5dbedd5abd744%2Fimage%20(509).png?alt=media" 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="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-b27602dae926c58dea4571117f525dd2e999827f%2Fimage%20(510).png?alt=media" 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="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-2a8009f8f0cf95cef9f7f000efe3de72419cc86e%2Fimage%20(511).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-6b9bc83db58e9145a0fdc3bda43e26f23f81db9d%2Fimage%20(30).png?alt=media" alt=""><figcaption></figcaption></figure>

อย่างที่คุณเห็น smart contract `MyToken.sol` เริ่มต้นนำเข้า smart contract `ERC20.sol` จาก OpenZeppelin\
*คุณสามารถเปิดไฟล์ `.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="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-9c0ee3c1c74b4c514f9f8dc7c92b8867ab66623c%2Fimage%20(535).png?alt=media" alt="" width="277"><figcaption></figcaption></figure></div>

5. คลิก "Compile\*\*"\*\* เหนือไฟล์ smart contract ของคุณ\
   ![](https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-b13eea1110eca19c6508903090705dd36402c66c%2Fimage%20\(515\).png?alt=media)

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

<div align="left"><figure><img src="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-faf54a139fb044bdb1f029b58fc9a9a3f0ea0df7%2Fimage%20(513).png?alt=media" alt="" width="338"><figcaption></figcaption></figure></div>

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

   <figure><img src="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-275762c2399f70b44cfccacd2fe3fc1906b1c087%2Fimage%20(516).png?alt=media" 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\
  ![](https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-a2e9fd5ec51c76a12d5055c77b2e0dc648814af5%2Fimage%20\(502\).png?alt=media)
* ตรวจสอบให้แน่ใจว่าเลือกไฟล์ smart contract ของคุณ และเวอร์ชัน EVM ที่เลือกคือ "Prague"\
  หากไม่ใช่ แสดงว่าเวอร์ชัน compiler ของคุณไม่ได้ตั้งค่าเป็น v0.8.30 (ดูด้านบน) ให้กลับไปที่ขั้นตอนที่ 4\
  ![](https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-486b515a6464678d53783705ccf7f84bf908cdb5%2Fimage%20\(504\).png?alt=media)
* คลิก "Deploy & Verify"\
  *หากคุณต้องการปรับใช้ smart contract ก่อนแล้วค่อยยืนยันด้วยตัวเอง คุณสามารถให้ Remix ปรับใช้ smart contract โดยยกเลิกการเลือกกล่อง "Verify Contract on Explorers"*

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

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

<figure><img src="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-f2435fed8a65ce1ee3375b394ca6f720fd029a79%2Fimage%20(505).png?alt=media" 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="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-f1e0501428b202591677c12ab53fc7c0372cbac4%2Fimage%20(507).png?alt=media" alt=""><figcaption></figcaption></figure>

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

<figure><img src="https://3189658150-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLHe6Yk9vM1NjniTq0hPb%2Fuploads%2Fgit-blob-436c5bb0dc2c30eea024e22bb06dda8a21fc7f54%2Fimage%20(28).png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
