> 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/sung-khuen/account-abstraction.md).

# ใช้งาน Account Abstraction

## Account Abstraction คืออะไร?

Account Abstraction คือเทคโนโลยี blockchain ที่ช่วยให้ผู้ใช้สามารถใช้ smart contract เป็นบัญชีของตนเอง ทำให้บัญชีสามารถตั้งโปรแกรมได้อย่างเต็มรูปแบบ

เทคโนโลยีนี้มุ่งเน้นให้บัญชีผู้ใช้มีความยืดหยุ่นและใช้งานได้หลากหลายมากขึ้น ส่งผลให้ประสบการณ์ผู้ใช้ดียิ่งขึ้น

## มีความหมายอย่างไรสำหรับนักพัฒนา Chiliz Chain?

การนำ AA มาใช้ช่วยให้นักพัฒนาสามารถพัฒนาประสบการณ์ผู้ใช้ของโปรเจกต์ตนเองได้ การโต้ตอบกับ Chiliz Chain ที่ง่ายขึ้นหมายถึงแอปที่ใช้งานสะดวกยิ่งขึ้น

## การใช้งาน Biconomy บน Chiliz Chain

[Biconomy](https://www.biconomy.io/) มีชุดเครื่องมือ Account Abstraction แบบ full-stack ที่สร้างขึ้นรอบ **MEE** (Modular Execution Environment) และ SDK **AbstractJS** ของตน โดย Chiliz Chain รองรับ[ทั้งบน Mainnet และ Spicy Testnet](https://docs.biconomy.io/contracts-and-audits/supported-chains)

ด้วย stack ของ Biconomy คุณสามารถมอบสิ่งเหล่านี้ให้ผู้ใช้ของคุณได้:

* ธุรกรรมแบบ Gasless
* ธุรกรรมแบบ batched และ cross-chain
* กระเป๋าเงินแบบ smart contract (รวมถึงการเข้าสู่ระบบด้วย social login)
* Modules ต่าง ๆ เช่น session keys, การกู้คืนบัญชี และอีกมากมาย

### ทำไมจึงเป็น MEE ไม่ใช่โมเดล Account Abstraction แบบคลาสสิก?

stack รุ่นก่อนหน้าของ Biconomy สร้างขึ้นบนโมเดล **ERC-4337** แบบคลาสสิก ซึ่งใช้โครงสร้างพื้นฐาน bundler และ paymaster แยกตามแต่ละ chain ต่อมา Biconomy ได้ย้ายไปใช้ **MEE** ที่คงความเทียบเท่ากับ ERC-4337 ได้อย่างเต็มรูปแบบพร้อมกับขจัดข้อจำกัดหลักออกไป การเปรียบเทียบ [MEE vs ERC-4337](https://docs.biconomy.io/new/learn-about-biconomy/mee-vs-4337) ของ Biconomy อธิบายเหตุผลไว้ดังนี้:

* **ความสามารถในการประกอบแบบไดนามิก (Dynamic composability):** ERC-4337 อนุญาตเฉพาะการ batch แบบ static เท่านั้น ซึ่งต้องทราบ call data ทั้งหมดล่วงหน้า แต่ MEE ให้แต่ละขั้นตอนสามารถอ้างอิงผลลัพธ์ของขั้นตอนก่อนหน้าได้ (logic แบบมีเงื่อนไข, ค่าที่เกิดขึ้นขณะ runtime)
* **การจัดการ cross-chain แบบเนทีฟ**: แทนที่จะต้องมีธุรกรรมและลายเซ็นแยกกันในแต่ละ chain MEE สามารถอนุมัติ flow แบบ multi-chain ที่ซับซ้อนได้ด้วยลายเซ็นเพียงครั้งเดียว
* **การ abstract ค่า gas แบบสากล**: ผู้ใช้สามารถจ่ายค่า gas บน chain ที่รองรับใด ๆ ก็ได้ด้วย token จากอีก chain หนึ่ง แทนที่จะต้องจัดการค่า gas แยกในแต่ละ chain
* **ระบบอัตโนมัติ**: MEE รองรับการทำงานตามกำหนดเวลาและแบบเกิดซ้ำ ซึ่งเป็นสิ่งที่ ERC-4337 ไม่มี
* **รองรับ EOA โดยค่าเริ่มต้น**: ไม่จำเป็นต้องมีกระเป๋าเงินแบบ smart contract (หรือ EIP-7702) อย่างเคร่งครัด

### ธุรกรรมแบบ Gasless บน Chiliz Chain

หนึ่งในการใช้งาน AA ที่ส่งผลกระทบมากที่สุดคือการขจัดความจำเป็นที่ผู้ใช้ต้องถือ CHZ เพียงเพื่อโต้ตอบกับ dApp ของคุณ ด้วย **ธุรกรรมแบบได้รับการสนับสนุน (sponsored/gasless)** แอปพลิเคชันของคุณจะครอบคลุมค่า gas แทนผู้ใช้ ทำให้การเริ่มต้นใช้งานไม่ต้องให้ผู้ใช้จัดหา CHZ มาก่อนอีกต่อไป และเมื่อผสานกับการ abstract ค่า gas แบบสากลของ MEE ก็สามารถจ่ายค่า gas ด้วย token อื่นแทน asset เนทีฟของ chain ได้อีกด้วย ดูวิธีเปิดใช้งานได้ที่คู่มือ [gas sponsorship](https://docs.biconomy.io/gasless-apps/sponsorship) ของ Biconomy

### เริ่มต้นใช้งาน

เข้าสู่ระบบ [Biconomy dashboard](https://dashboard.biconomy.io/) และสร้างโปรเจกต์ แต่ละโปรเจกต์จะให้ credentials ที่คุณจะใช้ในแอปของคุณ:

* **API Key** (เช่น `mee_LDxnuNsXYfvNUGsz6sJbHn`)
* **Project ID** (เช่น `1sp767r4-5rrs-9o1s-3s6s-4s0r6nrq3647`)

ติดตั้ง AbstractJS และ [viem](https://viem.sh/):

```bash
npm install @biconomy/abstractjs viem
```

จากนั้นสร้าง Nexus account และ MEE client โดยตั้งค่าคอนฟิก chain ให้ชี้ไปที่ Chiliz Chain โดย Chain ID ของ Chiliz Chain มีดังนี้:

* `Chiliz Mainnet = 88888`
* `Chiliz Spicy Testnet = 88882`

```typescript
import { createMeeClient, toMultichainNexusAccount, getMEEVersion, MEEVersion } from "@biconomy/abstractjs";
import { http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { chiliz, spicy } from "viem/chains";

const eoa = privateKeyToAccount("0xYOUR_PRIVATE_KEY");

// Create a Nexus account configured for Chiliz Chain (and Spicy Testnet)
const orchestrator = await toMultichainNexusAccount({
  chainConfigurations: [
    { chain: chiliz, transport: http(), version: getMEEVersion(MEEVersion.V2_1_0) },
    { chain: spicy, transport: http(), version: getMEEVersion(MEEVersion.V2_1_0) },
  ],
  signer: eoa,
});

// Create the MEE client using your Biconomy dashboard API key
const meeClient = await createMeeClient({
  account: orchestrator,
  apiKey: "mee_LDxnuNsXYfvNUGsz6sJbHn",
});
```

หมายเหตุ: SDK ของ Biconomy มีการพัฒนาอยู่เสมอ ดังนั้นโปรดทำตามคู่มือ [Setting up AbstractJS](https://docs.biconomy.io/new/getting-started/set-up-abstractjs) และ [introduction](https://docs.biconomy.io/overview/introduction) ของพวกเขาเพื่อดูตัวอย่างที่สมบูรณ์และเป็นปัจจุบัน


---

# 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/sung-khuen/account-abstraction.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.
