Rpc block explorer example #206
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces a new RPC Block Explorer tool for BNB Smart Chain (BSC), a BNBChain Cookbook demo that explores blocks and transactions via direct JSON-RPC calls. This lightweight block explorer demonstrates how to interact with blockchain data using standard Ethereum-compatible JSON-RPC methods without relying on third-party APIs or services.
Key Features:
eth_blockNumberRPC methodlatest,earliest,pending)eth_blockNumber,eth_getBlockByNumber,eth_getTransactionByHash,eth_getTransactionReceipt) directly with BSC RPC endpoints/api/latest,/api/block/:input,/api/transaction/:hash)JSON-RPC Methods Used:
eth_blockNumber— Get the latest block numbereth_getBlockByNumber— Fetch block data with optional full transaction detailseth_getTransactionByHash— Get transaction details by hasheth_getTransactionReceipt— Get transaction status (success/failed) and gas usageUse Cases:
Tech Stack:
fetchAPIThis implementation provides a complete, production-ready example that demonstrates best practices for direct RPC interaction with BSC, making blockchain data exploration accessible and educational.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce.
npm testto verify all RPC and formatting functions/api/latest,/api/block/:input,/api/transaction/:hash) return correct datanpm run build && npm startReproduction Steps:
./clone-and-run.sh(or manually:npm install,cp .env.example .env,npm run build,npm test,npm start)http://localhost:3000in a browser35000000) or hash and click "Search Block" to view block detailsChecklist: