Ethereum
هل أنت مستعد لاستدعاء هذا في الإنتاج؟
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
Ethereum
الخطة المجانية تغطي المشاريع الشخصية. الدفع حسب الاستخدام يتوسع دون بطاقة.
eth_getBlockTransactionCountByHash returns just one number: how many transactions are packed into the block with a given 32-byte hash on Ethereum mainnet. It's the lightweight cousin of eth_getBlockByHash — when all you need is the count, you skip transferring the entire block body. Because you address by hash, the answer is tied to one specific block regardless of any reorg around that height. The result is a hex integer, with 0x0 meaning an empty block (which still happens on Ethereum even though one is proposed every 12-second slot). Call it at https://ethereum.therpc.io/YOUR_API_KEY (chain ID 1, native coin ETH).
| # | الاسم | النوع | مطلوب | الوصف |
|---|---|---|---|---|
| 1 | blockHash | string (hex) | نعم | The hash of the block to count transactions in. |
| النوع | الوصف |
|---|---|
| string (hex) | Hex-encoded transaction count. "0x0" means the block is empty. |
Try it live in the Ethereum playground.
| الكود | الرسالة | السبب |
|---|---|---|
-32602 | Invalid params | Block hash is malformed or not 32 bytes. |
null, not 0x0. Null-check before you parseInt — feeding null to a hex parser is a quiet source of NaN counts.eth_getBlockTransactionCountByNumber does the same job and lets you pass tags like latest or finalized directly.المعاملات
0x-prefixed 32-byte block hash