---
title: "เอกสาร BNB Smart Chain RPC Endpoint"
description: "ใช้ ERPC เป็น BNB Smart Chain (BSC) RPC endpoint สำหรับ HTTP JSON-RPC requests"
canonical: "https://erpc.global/th/doc/bsc-rpc/general/"
locale: "th"
---

# เอกสาร BNB Smart Chain RPC Endpoint

## เอกสาร BNB Smart Chain RPC Endpoint

ใช้ ERPC เป็น BNB Smart Chain RPC endpoint ของคุณสำหรับ HTTP JSON-RPC requests ทั้งนี้ BNB Smart Chain RPC เป็นส่วนหนึ่งของ RPC APIs ของ ERPC ภายใน Global Edge Blockchain Infrastructure ของเรา และสามารถจัดการ API key ได้จาก ERPC Web Dashboard

คุณสามารถใช้ RPC key เดียวกับ Solana, Ethereum และ Avalanche ได้

ส่ง API key ของคุณผ่าน query parameter `api-key` หรือส่งเป็น `Authorization: Bearer <YOUR_API_KEY>` หากมีทั้งสองแบบ ระบบจะใช้ query parameter

### Endpoint

ส่ง JSON-RPC 2.0 requests แบบ HTTP POST ไปที่:

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

หรือส่งไปที่ host เฉพาะ:

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

รับ request ที่ `/` เท่านั้น

### ตัวอย่าง

นี่คือตัวอย่าง HTTP request ที่ใส่ API key ใน query parameter

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

นี่คือ request เดียวกันที่ใส่ API key ใน header `Authorization`

```bash
curl 'https://edge.erpc.global/bsc' --header 'Content-Type: application/json' --header 'Authorization: Bearer <YOUR_API_KEY>' --data '{
  "jsonrpc":"2.0","id":1,
  "method":"eth_blockNumber"
}'
```

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

### Request แบบ Batch

รองรับ JSON-RPC batch ตั้งแต่ 1 ถึง 100 คำสั่งเรียกต่อหนึ่ง HTTP request แต่ละคำสั่งเรียกต้องมี `id` ของตัวเอง และค่า `id` ต้องไม่ซ้ำกันภายใน batch เดียวกัน แต่ละคำสั่งเรียกในหนึ่ง batch จะถูกวัดเป็นคำสั่งเรียกแยกกัน request body มีขนาดได้สูงสุด 1 MiB

### การวัดผลการใช้งาน

การใช้งานจะถูกวัดเป็น token และอัตรา token อาจแตกต่างกันไปตาม method แต่ละคำสั่งเรียกในหนึ่ง HTTP batch จะถูกวัดแยกกัน

### ข้อจำกัดของแพ็กเกจ Free

ในแพ็กเกจ Free บัญชีของคุณส่งได้หนึ่ง request ต่อ 10 วินาที ขีดจำกัดนี้นับต่อบัญชี ไม่ใช่ต่อ endpoint ดังนั้น request ที่ส่งไปยัง chain อื่นก็อาจถูกนับรวมในขีดจำกัดนี้ด้วย request ที่ส่งเร็วกว่านั้นจะได้รับการตอบกลับด้วย HTTP `429` และ header `retry-after` จะระบุเวลาที่ต้องรอเป็นวินาที

ในแพ็กเกจ Free request ที่มีคำสั่งเรียก JSON-RPC ตั้งแต่ 2 รายการขึ้นไปจะได้รับการตอบกลับด้วย HTTP `429` และจะไม่มีคำสั่งเรียกใดถูกส่งเลย: แต่ละคำสั่งเรียกจะได้รับ JSON-RPC error ที่มีรหัส `-32041` ให้ส่งคำสั่งเรียกเหล่านี้ทีละรายการแทน

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

Endpoint นี้ให้บริการ method ต่อไปนี้ 38 รายการ โดยจัดกลุ่มตาม namespace

- `eth_*` (24): `eth_blockNumber`, `eth_call`, `eth_chainId`, `eth_estimateGas`, `eth_feeHistory`, `eth_gasPrice`, `eth_getBalance`, `eth_getBlockByHash`, `eth_getBlockByNumber`, `eth_getBlockReceipts`, `eth_getBlockTransactionCountByHash`, `eth_getBlockTransactionCountByNumber`, `eth_getCode`, `eth_getLogs`, `eth_getProof`, `eth_getStorageAt`, `eth_getTransactionByBlockHashAndIndex`, `eth_getTransactionByBlockNumberAndIndex`, `eth_getTransactionByHash`, `eth_getTransactionCount`, `eth_getTransactionReceipt`, `eth_maxPriorityFeePerGas`, `eth_sendRawTransaction`, `eth_syncing`
- `net_*` (3): `net_listening`, `net_peerCount`, `net_version`
- `web3_*` (2): `web3_clientVersion`, `web3_sha3`
- `txpool_*` (3): `txpool_content`, `txpool_inspect`, `txpool_status`
- `debug_*` (4): `debug_traceBlockByHash`, `debug_traceBlockByNumber`, `debug_traceCall`, `debug_traceTransaction`
- `trace_*` (2): `trace_block`, `trace_transaction`

method หรือ path ที่ไม่อยู่ในรายการจะได้รับการตอบกลับด้วย HTTP `400`

### รหัสสถานะการตอบกลับ

| สถานะ HTTP | ความหมาย |
| --- | --- |
| 200 | การตอบกลับ JSON-RPC จาก upstream ส่วน JSON-RPC error จะถูกส่งกลับด้วย HTTP `200` เช่นกัน: คง `id` ของ request และ `error.code` ไว้ ค่า `error.message` เป็น `ERPC upstream error` และไม่ส่ง `error.data` กลับมา |
| 400 | method หรือ path ที่ไม่อยู่ในรายการเมธอดที่รองรับ, JSON-RPC request ไม่ถูกต้อง, batch ว่างหรือ batch ที่เกิน 100 คำสั่งเรียก, `id` ซ้ำกันใน batch หรือ body ที่เกิน 1 MiB |
| 401 | ไม่มี API key หรือ API key ไม่ถูกต้อง หรือไม่เป็นไปตามข้อจำกัด IP หรือ Origin ที่ตั้งไว้สำหรับ key |
| 405 | ใช้ request method อื่นที่ไม่ใช่ POST |
| 426 | มีการร้องขอ WebSocket Upgrade แต่ endpoint นี้รองรับเฉพาะ HTTP |
| 429 | ถูกจำกัดอัตรา รวมถึงข้อจำกัดของแพ็กเกจ Free ข้างต้น: มากกว่าหนึ่ง request ต่อ 10 วินาที หรือมีคำสั่งเรียกตั้งแต่ 2 รายการขึ้นไปใน request เดียว หากมี header `retry-after` ให้รอตามจำนวนวินาทีที่ระบุ |
| 502 | ไม่สามารถดำเนินการ upstream request ให้เสร็จสมบูรณ์ได้: upstream ตอบกลับล้มเหลว, การตอบกลับเกิน 8 MiB หรือไม่มีการตอบกลับภายใน 30 วินาที |
| 503 | บริการไม่พร้อมใช้งานชั่วคราว |

### เมธอดและเอกสารของ BNB Smart Chain RPC

สำหรับรายการ method มาตรฐาน พารามิเตอร์ และข้อกำหนดทั้งหมด โปรดดูเอกสารทางการ

[https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/json-rpc-endpoint/](https://docs.bnbchain.org/bnb-smart-chain/developers/json_rpc/json-rpc-endpoint/)
