เอกสาร Ethereum RPC Endpoint
เอกสาร Ethereum RPC Endpoint
ใช้ ERPC เป็น Ethereum RPC endpoint ของคุณสำหรับ HTTP JSON-RPC requests และ WebSocket subscriptions ทั้งนี้ Ethereum RPC เป็นส่วนหนึ่งของ RPC APIs ของ ERPC ภายใน Global Edge Blockchain Infrastructure ของเรา และสามารถจัดการ API key ได้จาก ERPC Web Dashboard
คุณสามารถใช้ RPC key เดียวกับ Solana ได้
โปรดเพิ่ม API key ของคุณในพารามิเตอร์ 'api-key'
Endpoint
ส่ง JSON-RPC 2.0 requests แบบ HTTP POST ไปที่:
endpoint
สำหรับ subscription ให้เชื่อมต่อผ่าน WebSocket ไปที่:
endpoint
ตัวอย่าง
นี่คือตัวอย่าง HTTP request
bash
นี่คือตัวอย่าง WebSocket subscription
bash
คุณสามารถสร้างและตรวจสอบ API key ได้ใน ERPC Web Dashboard: ERPC Web Dashboard
Request แบบ Batch
รองรับ JSON-RPC batch สูงสุด 256 คำสั่งเรียกต่อหนึ่ง HTTP request และรองรับ JSON-RPC notification ด้วยเช่นกัน แต่ละคำสั่งเรียกในหนึ่ง batch จะถูกวัดเป็นคำสั่งเรียกแยกกัน
การวัดผลการใช้งาน
คำสั่งเรียกแต่ละครั้งจะใช้ token ตามจำนวนที่กำหนดไว้สำหรับ method ที่เรียก คำสั่งเรียกใน HTTP batch และคำสั่งเรียกที่ส่งผ่านการเชื่อมต่อ WebSocket จะนับแยกเป็นรายการละหนึ่งครั้ง นอกจากนี้ การแจ้งเตือนแต่ละรายการที่คุณได้รับจาก subscription ผ่าน WebSocket ก็ใช้ token เช่นกัน ทั้งนี้ หน้า การใช้งาน API ของแดชบอร์ดจะแสดง token หนึ่งหน่วยเป็น Credit หนึ่งหน่วย
จำนวน token ต่อคำสั่งเรียกที่ส่งผ่าน HTTP และ WebSocket มีดังนี้:
เวลาประมาณการจำนวน token ให้คิดคำสั่งเรียกในแถว "81, 162 หรือ 324" เป็น 324 tokens ซึ่งเป็นค่าสูงสุดในสามค่านี้
method ต่อไปนี้ใช้ 42 tokens ต่อคำสั่งเรียก:
eth_*(41):eth_accounts,eth_baseFee,eth_blobBaseFee,eth_blockNumber,eth_call,eth_capabilities,eth_chainId,eth_createAccessList,eth_estimateGas,eth_feeHistory,eth_gasPrice,eth_getAccount,eth_getBalance,eth_getBlockByHash,eth_getBlockByNumber,eth_getBlockReceipts,eth_getBlockTransactionCountByHash,eth_getBlockTransactionCountByNumber,eth_getCode,eth_getFilterChanges,eth_getProof,eth_getRawTransactionByHash,eth_getStorageAt,eth_getTransactionByBlockHashAndIndex,eth_getTransactionByBlockNumberAndIndex,eth_getTransactionByHash,eth_getTransactionBySenderAndNonce,eth_getTransactionCount,eth_getTransactionReceipt,eth_getUncleCountByBlockHash,eth_getUncleCountByBlockNumber,eth_maxPriorityFeePerGas,eth_newBlockFilter,eth_newFilter,eth_newPendingTransactionFilter,eth_signTransaction,eth_submitWork,eth_subscribe,eth_syncing,eth_uninstallFilter,eth_unsubscribenet_*(3):net_listening,net_peerCount,net_versionweb3_*(2):web3_clientVersion,web3_sha3
method ต่อไปนี้ใช้ 81 tokens ต่อคำสั่งเรียก:
eth_*(18):eth_cancelPrivateTransaction,eth_coinbase,eth_getHeaderByNumber,eth_getRawTransactionByBlockHashAndIndex,eth_getRawTransactionByBlockNumberAndIndex,eth_getUncleByBlockHashAndIndex,eth_getUncleByBlockNumberAndIndex,eth_getUserOperationReceipt,eth_getWork,eth_hashrate,eth_mining,eth_pendingTransactions,eth_protocolVersion,eth_sendPrivateTransaction,eth_sendTransaction,eth_sign,eth_submitHashRate,eth_submitHashrate
method ต่อไปนี้ใช้ 162 tokens ต่อคำสั่งเรียก:
debug_*(11):debug_gcStats,debug_getBadBlocks,debug_getBlockReceipts,debug_getTrieFlushInterval,debug_storageRangeAt,debug_traceBlock,debug_traceBlockByHash,debug_traceBlockByNumber,debug_traceCall,debug_traceCallMany,debug_traceTransactiontrace_*(6):trace_block,trace_call,trace_filter,trace_get,trace_rawTransaction,trace_transaction
การแจ้งเตือนของ subscription แต่ละรายการที่คุณได้รับผ่าน WebSocket (
wss://edge.erpc.global/eth) ใช้ 42 tokens การแจ้งเตือนของ subscription คือข้อความ eth_subscription ที่เซิร์ฟเวอร์ส่งมาหลังจากคุณ subscribe ด้วย eth_subscribe แล้วข้อความแต่ละรายการที่คุณส่งผ่านการเชื่อมต่อ แต่ระบบอ่านเป็นคำสั่งเรียก JSON-RPC ไม่ได้ ก็ใช้ 42 tokens เช่นกัน
คุณสามารถตรวจสอบอัตรา token ต่อคำสั่งเรียกปัจจุบันได้ใน ข้อมูลอ้างอิง Ethereum RPC API
เมธอดที่รองรับ
Endpoint นี้ครอบคลุมกลุ่ม method มาตรฐานของ Ethereum JSON-RPC —
eth_*, net_*, txpool_* และ web3_* — รวมถึงการอ่านบัญชีและบล็อก (eth_getBalance, eth_getBlockByNumber, eth_getLogs), การทำธุรกรรม (eth_sendRawTransaction, eth_getTransactionReceipt), ข้อมูลค่าธรรมเนียม (eth_feeHistory, eth_maxPriorityFeePerGas), การจำลองการเรียก (eth_call, eth_callMany, eth_simulateV1), state proof (eth_getProof), filter (eth_newFilter, eth_getFilterChanges), การตรวจสอบ txpool (txpool_status, txpool_content) และ WebSocket subscription (eth_subscribe, eth_unsubscribe)สำหรับรายการ method ทั้งหมดพร้อมรูปแบบ request และ response โปรดดู ข้อมูลอ้างอิง Ethereum RPC API
รหัสสถานะการตอบกลับ
การเชื่อมต่อ WebSocket ใช้
101 (ยอมรับการอัปเกรดโปรโตคอล) นอกเหนือจากรหัสด้านบนเมธอดและเอกสารของ Ethereum RPC
สำหรับรายการ method มาตรฐาน พารามิเตอร์ และข้อกำหนด subscription ทั้งหมด โปรดดูเอกสารทางการ ซึ่งครอบคลุมการใช้งานทั้ง HTTP และ WebSocket






