---
title: "Solana RPC Endpoint Documentation"
description: "ตั้งค่า ERPC เป็น Solana RPC endpoint ความหน่วงต่ำสำหรับ HTTP JSON-RPC request, WebSocket subscription และ Solana endpoint สำหรับ production"
canonical: "https://erpc.global/th/doc/rpc/general/"
locale: "th"
---

# Solana RPC Endpoint Documentation

## เอกสาร Solana RPC Endpoint

ใช้ ERPC เป็น Solana RPC endpoint สำหรับส่ง HTTP JSON-RPC requests และรับ WebSocket subscriptions. Solana endpoint URL เดียวกันรองรับ RPC methods มาตรฐาน และคุณสามารถจัดการ API key ได้จาก ERPC Web Dashboard.

เพิ่ม API key ของคุณในพารามิเตอร์ `api-key`.

```text
https://edge.erpc.global?api-key=<YOUR_API_KEY>
```

### ตัวอย่าง

ตัวอย่าง HTTP request:

```bash
curl https://edge.erpc.global?api-key=<YOUR_API_KEY> --header 'Content-Type: application/json' --data '{
  "jsonrpc":"2.0","id":1,
  "method":"getBlockHeight"
}'
```

ตัวอย่าง WebSocket subscription. Host ใช้โดเมนเดียวกับ HTTP.

```text
wss://edge.erpc.global?api-key=<YOUR_API_KEY>
```

```bash
# Example: subscribe to slot updates
wscat -c "wss://edge.erpc.global?api-key=<YOUR_API_KEY>"
# After connected, send:
{"jsonrpc":"2.0","id":1,"method":"slotSubscribe"}
```

คุณสามารถสร้างและตรวจสอบ API key ได้ใน ERPC Web Dashboard: [ERPC Web Dashboard](https://dashboard.erpc.global/th)

หากต้องการ latency ต่ำกว่า WebSocket ให้พิจารณา Geyser gRPC หรือ ShredStream และติดต่อเราเพื่อหารายละเอียดผ่าน ERPC Web Dashboard.

### History Access

เพิ่ม `history=true` ใน URL `edge.erpc.global` ของ HTTP request เพื่อค้นหาบล็อกและธุรกรรมที่เก่ากว่า ค่าต้องเป็น `true` ตรงตัว และเป็นตัวพิมพ์เล็ก นอกจาก `getTransactionsForAddress` แล้ว request ที่ไม่มี `history=true` จะได้รับคำตอบจากช่วงข้อมูลล่าสุดที่แต่ละ node เก็บไว้ ตัวเลือกนี้ใช้กับ method ต่อไปนี้:

- `getBlock`
- `getBlockTime`
- `getBlocks`
- `getBlocksWithLimit`
- `getTransaction` รวมถึง `getParsedTransaction`
- `getSignaturesForAddress`
- `getSignatureStatuses` เมื่อ `searchTransactionHistory` เป็น `true`
- `getTransactionsForAddress` เมื่อ `transactionDetails` เป็น `"full"` (ต้องใช้ History Access)

ใส่ API key และตัวเลือกใน URL เป็น query parameter:

```text
https://edge.erpc.global?api-key=<YOUR_API_KEY>&history=true
```

หรือส่ง `Authorization: Bearer <YOUR_API_KEY>` เป็น header โดยให้ตัวเลือกอยู่ใน URL:

```text
https://edge.erpc.global?history=true
```

ตัวอย่าง HTTP request ที่ใช้ History Access:

```bash
curl 'https://edge.erpc.global?history=true' \
  --header 'Authorization: Bearer <YOUR_API_KEY>' \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc":"2.0","id":1,
  "method":"getBlock",
  "params":[<SLOT>,{"maxSupportedTransactionVersion":1}]
}'
```

สำหรับทุก method ยกเว้น `getTransactionsForAddress` ในโหมด `"full"`:

- การเรียกแต่ละครั้งที่ History Access ตอบจะใช้มากกว่าราคาปกติ 640 tokens: `getBlock` ใช้ 42 + 640 = 682
- ผลลัพธ์ `null` ว่าง หรือบางส่วนจาก History Access มีค่าใช้จ่ายเพิ่มเติมเช่นกัน การค้นหาที่ล้มเหลวไม่มีค่าใช้จ่ายเพิ่มเติม
- การเรียกที่ตอบจากข้อมูลล่าสุดยังคงใช้ราคาปกติ แม้จะมี `history=true`
- batch นับแต่ละการเรียกแยกกัน; `getSignatureStatuses` นับหนึ่งครั้งต่อการเรียก ไม่ใช่ต่อ signature
- อย่าใส่ `history=true` ในการ polling ธุรกรรมล่าสุด: ทุก `null` ที่นั่นมีค่าใช้จ่ายเพิ่มเติมเช่นกัน

โควตาฟรี รวมถึงของแพ็กเกจ Free มีขีดจำกัดสำหรับ History Access แพ็กเกจ Free จำกัดไว้ที่หนึ่ง request ของ History Access ต่อ 10 วินาที

การเรียก `getTransactionsForAddress` ที่ตั้งค่า `transactionDetails` เป็น `"full"` คือ History Access ไม่ว่าธุรกรรมจะล่าสุดหรือเก่า:

- การเรียกนี้ต้องมี `history=true` ใน URL `edge.erpc.global` ส่วน request ที่ไม่มีตัวเลือกนี้จะถูกปฏิเสธด้วย error ของ History Access (code `-32011`) และไม่มีค่าใช้จ่าย
- เมื่อมี `history=true` การเรียกนี้ใช้ 420 + 640 × N tokens: ราคาปกติ 420 บวก 640 สำหรับธุรกรรมแต่ละรายการจาก N รายการที่ดึงมา ไม่ว่าจะล่าสุดหรือเก่า แถวที่ไม่มีธุรกรรมจะไม่ถูกนับ
- ต้องส่งการเรียกนี้เป็น request แยกต่างหาก batch ที่มีการเรียกนี้จะถูกปฏิเสธ ไม่ว่าจะมีหรือไม่มี `history=true`: ทุกการเรียกใน batch จะได้รับ error `-32600` พร้อมข้อความ `This request is not available in a mixed JSON-RPC batch. Please send it as a separate request.` และจะไม่มีการเรียกใดถูกส่ง

โหมด `signatures` เริ่มต้นไม่ต้องใช้ `history=true` และไม่มีค่าใช้จ่ายเพิ่มเติม หากต้องการ poll ที่อยู่เพื่อหาธุรกรรมใหม่ ให้ใช้โหมด `signatures` แล้วดึงธุรกรรมที่ต้องการด้วย `getTransaction`

การค้นหาบล็อกหรือธุรกรรมที่เก่ากว่าอาจใช้เวลานานกว่า request ปกติมาก ในบางกรณีนานเป็นวินาที History Access เป็นตัวเลือกแยกต่างหากที่แยกการค้นหาเหล่านี้ออกจาก request ปกติ เพื่อให้ request ปกติยังคงเร็ว

หากไม่มี `history=true` request `getBlock` หรือ `getBlockTime` สำหรับ slot ที่เก่ากว่าอาจคืนค่า error นี้:

```json
{
  "jsonrpc": "2.0",
  "error": {
    "code": -32011,
    "message": "This request needs history access. Add history=true to the endpoint URL.",
    "data": {
      "erpcCode": "ERPC_HISTORY_OPTION_REQUIRED"
    }
  },
  "id": 1
}
```

`getTransaction`, `getParsedTransaction` และ `getSignatureStatuses` (เมื่อใช้ `searchTransactionHistory: true`) คืนค่า `null` สำหรับ signature ที่เก่ากว่าที่ node เก็บไว้ ส่วน `getSignaturesForAddress`, `getBlocks` และ `getBlocksWithLimit` คืนผลลัพธ์ว่างหรือบางส่วน

request ที่มี `history=true` อาจได้รับข้อความต่อไปนี้:

- `This plan has reached its limit for history access. Add a paid plan to use tokens for history access.` — แสดงเมื่อโควตาฟรี เช่นของแพ็กเกจ Free ถึงขีดจำกัด
- `History access is unavailable while your token balance is low. Add tokens.` — แสดงในแพ็กเกจแบบชำระเงินเมื่อยอด tokens คงเหลือต่ำ
- `On the Free plan, history access is limited to one request per 10 seconds. Slow down or use a paid plan.` — แสดงในแพ็กเกจ Free เมื่อ request ของ History Access เข้ามาเร็วเกินไป

### เมธอดที่ Unlimited Endpoint รองรับ

Unlimited Endpoints คือ HTTP endpoint เฉพาะที่ปรับให้เหมาะกับการเรียก Solana RPC มาตรฐานที่มีความหน่วงต่ำ เมธอด Solana RPC มาตรฐานที่รองรับมีดังนี้:

- `getSlot`
- `getBlockHeight`
- `getLatestBlockhash`
- `getBalance`
- `getAccountInfo`
- `getMultipleAccounts`
- `getTransaction`
- `sendTransaction`
- `simulateTransaction`
- `getSignatureStatuses`
- `getRecentPrioritizationFees`
- `getHealth`
- `getVersion`
- `getEpochInfo`
- `getBlock`

สำหรับเมธอดที่อยู่นอกชุดที่รองรับนี้ ให้ใช้ `https://edge.erpc.global?api-key=<YOUR_API_KEY>`

### Solana RPC Methods และ Documentation

สำหรับรายการ methods, parameters และ subscription specifications ทั้งหมด โปรดดูเอกสารทางการ ซึ่งครอบคลุมการใช้งานทั้ง HTTP และ WebSocket.

[https://solana.com/docs/rpc](https://solana.com/docs/rpc)
