BNB Smart Chain
准备好在生产环境中调用了吗?
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
BNB Smart Chain
免费套餐涵盖个人项目。按量付费,无需绑卡即可扩展。
This page collects the BNB Smart Chain calls developers reach for on day one: the latest block height, a BNB or BEP-20 balance, a transaction and its receipt, full blocks, a contract view function, and the gas price and nonce you need before sending. Each one is shown as a ready-to-run JSON-RPC payload you can POST to https://bsc.therpc.io/YOUR_API_KEY.
Two reads anchor almost every BNB Smart Chain integration. eth_blockNumber returns the latest block height, a quick way to confirm the node is synced and live. eth_getBalance returns an account's holdings, but the value comes back in wei as a hex string; divide it by 10^18 to express it as BNB before showing it to a user.
Two calls cover transaction lookups on BNB Smart Chain. eth_getTransactionByHash fetches a transaction by its hash and tells you whether it is still pending or already mined. eth_getTransactionReceipt returns the full receipt once it has been included. The receipt carries the block it landed in, the gas used, the success status, and any emitted logs such as BEP-20 Transfer events.
You can fetch a BNB Smart Chain block two ways. eth_getBlockByNumber takes a hex height (or a tag like latest), while eth_getBlockByHash takes the block's hash. Both accept a boolean second argument. Pass true to receive every transaction as a full object, or false to get back only the transaction hashes and keep the response light.
Two methods read contracts without spending gas. eth_call executes a view function locally against the current state (for example calling balanceOf on a BEP-20 token or quoting a price from a PancakeSwap pair) and returns the ABI-encoded result. eth_getCode returns the deployed bytecode at an address, which lets you confirm a contract exists there rather than a plain wallet.
Two calls report on the network itself. net_version returns the chain ID as a string, 56 for BNB Smart Chain mainnet, which is handy for asserting your client is pointed at the right network. eth_syncing reports whether the backing node is still catching up, returning false when it is fully synced or a progress object while it is not.
Before broadcasting a BNB Smart Chain transaction you need two values. eth_gasPrice returns the current price in wei, which on BNB Smart Chain stays low thanks to the chain's economics. eth_getTransactionCount returns an address's nonce, the count of transactions it has already sent. That nonce is what orders outgoing transactions, so each new send must use the next value to avoid being rejected or stuck.