Bsc RPC
How to use it
// yarn add @tatumio/tatum
import { TatumSDK, BinanceSmartChain, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<BinanceSmartChain>({ network: Network.BINANCE_SMART_CHAIN })
const blockTrace = await tatum.rpc.traceBlock({ blockNumber: 40490463 })
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs
Overview
trace_block
is a JSON-RPC method that allows you to fetch the trace details for a given block based on the block height. This method can be useful when you need detailed trace information for a specific block.
Use cases for this method may include:
- Analyzing the internal operations of transactions within a block
- Debugging smart contract interactions
- Collecting data for in-depth blockchain analytics
Parameters
The trace_block
method accepts one parameter:
blockNumber
(required): The height of the block for which you want to fetch trace details.- Example:
40490463
- Example:
Return Object
The method returns a JSON object containing trace details of the specified block. The structure of the returned object includes the following fields:
action
: An object containing details about the action performed in the trace.from
: The address of the sender.callType
: The type of call made (e.g., "call").gas
: The amount of gas provided by the sender.input
: The input data sent along with the transaction.to
: The address of the recipient.value
: The value transferred in wei.
blockHash
: The hash of the block containing the trace.blockNumber
: The height of the block containing the trace.result
: An object containing the result of the trace.gasUsed
: The amount of gas used by the transaction.output
: The output data from the transaction.
subtraces
: The number of subtraces within this trace.traceAddress
: An array indicating the trace address.transactionHash
: The hash of the transaction containing the trace.transactionPosition
: The position of the transaction within the block.type
: The type of the trace (e.g., "call").
JSON Examples
Request:
{
"jsonrpc": "2.0",
"id": 67,
"method": "trace_block",
"params": [40490463]
}
Response:
{
"jsonrpc": "2.0",
"id": 67,
"result": [
{
"action": {
"from": "0x9239df3e9996c776d539eb9f01a8ae8e7957b3c3",
"callType": "call",
"gas": "0x74c88",
"input": "0xa9059cbb000000000000000000000000b0fdccfe7d67c9942b527b5e1e86a3532bf8d8fd000000000000000000000000000000000000000000000047c2966534a395f000",
"to": "0x55d398326f99059ff775485246999027b3197955",
"value": "0x0"
},
"blockHash": "0x7cfa5bfa1939785b972e5fb6221f267a035b0776dd3768cf108d1956a313dedc",
"blockNumber": 40490463,
"result": {
"gasUsed": "0x7513",
"output": "0x0000000000000000000000000000000000000000000000000000000000000001"
},
"subtraces": 0,
"traceAddress": [],
"transactionHash": "0xea6ad9a530297fd4eade4a7104d058d8c117e287be667661ee3139fe69e13eb7",
"transactionPosition": 0,
"type": "call"
}
]
}