BNB Smart Chain — eth, trace, debug
API reference for BNB Smart Chain. All methods ->
eth_getUncleByBlockHashAndIndex
Returns information about an uncle of a block by hash and uncle index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(data, 32 bytes): the hash of a block.<string>(quantity): the uncle's index position.
Returns
<object>: a block object, or null when no block was found:number(string; quantity): the block number; null when it's a pending block.hash(string; data, 32 bytes): the hash of the block; null when it's a pending block.parentHash(string; data, 32 bytes): the hash of the parent block.nonce(string; data, 8 bytes): the hash of the generated proof-of-work; null when it's a pending block.sha3Uncles(string; data, 32 bytes): SHA3 of the uncles data in the block.logsBloom(string; data, 256 bytes): the bloom filter for the logs of the block. null when its pending block.transactionsRoot(string; data, 32 bytes): the root of the transaction trie of the block.stateRoot(string; data, 32 bytes): the root of the final state trie of the block.receiptsRoot(string; data, 32 bytes): the root of the receipts trie of the block.miner(string; data, 20 bytes): the address of the beneficiary to whom the mining rewards were given.difficulty(string; quantity): the difficulty for this block.totalDifficulty(string; quantity): the total difficulty of the chain until this block.extraData(string; data): the extra data field of this block.size(string; quantity): the size of this block in bytes.gasLimit(string; quantity): the maximum gas allowed in this block.gasUsed(string; quantity): the total used gas by all transactions in this block.timestamp(string; quantity): the unix timestamp for when the block was collated.transactions(array of strings): an array of transaction objects, or 32 bytes transaction hashes depending on the last given parameter.uncles(array of strings): an array of uncle hashes.
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": ["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difficulty": "0x4ea3f27bc",
"extraData": "0x476574682f4c5649562f76312e302e302f6c696e75782f676f312e342e32",
"gasLimit": "0x1388",
"gasUsed": "0x0",
"hash": "0xdc0818cf78f21a8e70579cb46a43643f78291264dda342ae31049421c82d21ae",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0xbb7b8287f3f0a933474a79eae42cbca977791171",
"mixHash": "0x4fffe9ae21f1c9e15207b1f472d5bbdd68c9595d461666602f2be20daf5e7843",
"nonce": "0x689056015818adbe",
"number": "0x1b4",
"parentHash": "0xe99e022112df268087ea7eafaf4790497fd21dbeeb6bd7a1721df161a6657a54",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x220",
"stateRoot": "0xddc8b0234c2e0cad087c8b389aa7ef01f7d79b2570bccb77ce48648aa61c904d",
"timestamp": "0x55ba467c",
"totalDifficulty": "0x78ed983323d",
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}
eth_getUncleByBlockNumberAndIndex
Returns information about an uncle of a block by number and uncle index position.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<string>(quantity|tag): either the hex value of a block number or one of the following block tags:earliest: the lowest numbered block available on the client.finalized: the most recent crypto-economically secure block; cannot be re-orged outside of manual intervention driven by community coordination.safe: the most recent block that is safe from re-orgs under honest majority and certain synchronicity assumptions.latest: the most recent block in the canonical chain observed by the client; this block can be re-orged out of the canonical chain even under healthy/normal conditions.pending: a sample next block built by the client on top of thelatestand containing the set of transactions usually taken from local mempool. In other words, it is the block that has not been mined yet.
<string>(quantity): the uncle's index position.
Returns
<object>: a block object, or null when no block was found:number(string; quantity): the block number; null when it's a pending block.hash(string; data, 32 bytes): the hash of the block; null when it's a pending block.parentHash(string; data, 32 bytes): the hash of the parent block.nonce(string; data, 8 bytes): the hash of the generated proof-of-work; null when it's a pending block.sha3Uncles(string; data, 32 bytes): SHA3 of the uncles data in the block.logsBloom(string; data, 256 bytes): the bloom filter for the logs of the block. null when its pending block.transactionsRoot(string; data, 32 bytes): the root of the transaction trie of the block.stateRoot(string; data, 32 bytes): the root of the final state trie of the block.receiptsRoot(string; data, 32 bytes): the root of the receipts trie of the block.miner(string; data, 20 bytes): the address of the beneficiary to whom the mining rewards were given.difficulty(string; quantity): the difficulty for this block.totalDifficulty(string; quantity): the total difficulty of the chain until this block.extraData(string; data): the extra data field of this block.size(string; quantity): the size of this block in bytes.gasLimit(string; quantity): the maximum gas allowed in this block.gasUsed(string; quantity): the total used gas by all transactions in this block.timestamp(string; quantity): the unix timestamp for when the block was collated.transactions(array of strings): an array of transaction objects, or 32 bytes transaction hashes depending on the last given parameter.uncles(array of strings): an array of uncle hashes.
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockNumberAndIndex",
"params": ["0x29c", "0x0"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"difficulty": "0x57f117f5c",
"extraData": "0x476574682f76312e302e302f77696e646f77732f676f312e342e32",
"gasLimit": "0x1388",
"gasUsed": "0x0",
"hash": "0x932bdf904546a2287a2c9b2ede37925f698a7657484b172d4e5184f80bdd464d",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"miner": "0x5bf5e9cf9b456d6591073513de7fd69a9bef04bc",
"mixHash": "0x4500aa4ee2b3044a155252e35273770edeb2ab6f8cb19ca8e732771484462169",
"nonce": "0x24732773618192ac",
"number": "0x299",
"parentHash": "0xa779859b1ee558258b7008bbabff272280136c5dd3eb3ea3bfa8f6ae03bf91e5",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x21d",
"stateRoot": "0x2604fbf5183f5360da249b51f1b9f1e0f315d2ff3ffa1a4143ff221ad9ca1fec",
"timestamp": "0x55ba4827",
"totalDifficulty": "0xc46826a2c6a",
"transactions": [],
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}
eth_getLogs
Returns an array of all logs matching a given filter object.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):-
object: the filter options:-
fromBlock(string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:latest: for the last mined block.earliest: for the lowest numbered block available on the client.pending: for not yet mined transactions.
-
toBlock(string; quantity|tag; optional; default: "latest"): either the block number or one of the following block tags:latest: for the last mined block.earliest: for the lowest numbered block available on the client.pending: for not yet mined transactions.
-
address(array of strings; data, 20 bytes; optional): a contract address or a list of addresses from which logs should originate. -
topics(array of strings; data; optional): an array of 32 bytes data topics. Topics are order-dependent. Each topic can also be an array of data with "or" options. -
blockhash(string; data, 32 bytes; optional; future): with the addition of EIP-234,blockHashwill be a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent tofromBlock = toBlock = the blocknumber with hash blockHash. IfblockHashis present in the filter criteria, then neitherfromBlocknortoBlockare allowed.
-
-
Returns
removed(string; tag):truewhen the log was removed, due to a chain reorganization;falseif it's a valid log.logIndex(string; quantity): the log index position in the block; null when it's a pending log.transactionIndex(string; quantity): the transactions index position log was created from; null when it's a pending log.transactionHash(string; data, 32 bytes): a hash of the transactions this log was created from; null when it's a pending log.blockHash(string; data, 32 bytes): a hash of the block containing the log; null when it's pending; null when it's a pending log.blockNumber(string; quantity): the number of the block containing the log; null when it's pending; null when it's a pending log.address(string; data, 20 bytes): an address from which this log originated.data(string; data): contains one or more 32 bytes non-indexed arguments of the log.topics(array of strings; data): an array of 0 to 4 32 bytes data of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g. Deposit(address,bytes32,uint256)), except you declared the event with the anonymous specifier.)
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{"address": "0xdAC17F958D2ee523a2206206994597C13D831ec7"}],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000009acbb72cf67103a30333a32cd203459c6a9c3311",
"0x000000000000000000000000994871e1103c5da4be270365fa62771ea4525520"
],
"data": "0x000000000000000000000000000000000000000000000000000000001ec39aa0",
"blockNumber": "0xf6289d",
"transactionHash": "0xc7ed73c9b219d4243872e5993ad2950c8ea87d15af28562d33b0c05d46a90cee",
"transactionIndex": "0x1e",
"blockHash": "0x1e12377f0357320c0e5cfcadc2dfbc9c75fc339be668e118c34e4333f835ef31",
"logIndex": "0x13",
"removed": false
},
{
"address": "0xdac17f958d2ee523a2206206994597c13d831ec7",
"topics": [
"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
"0x0000000000000000000000005879975799597392c031f10b6eff282cb7974ac8",
"0x0000000000000000000000006d52ab66340f3f78d0c1007bec484268876b5948"
],
"data": "0x0000000000000000000000000000000000000000000000000000000000000000",
"blockNumber": "0xf6289d",
"transactionHash": "0x0118499f7be4c3510bd60fe3a3aee5f5f316743b6cc13a8cb0528d784f962aec",
"transactionIndex": "0x20",
"blockHash": "0x1e12377f0357320c0e5cfcadc2dfbc9c75fc339be668e118c34e4333f835ef31",
"logIndex": "0x14",
"removed": false
}
]
}
trace_filter
Retrieve traces that match filter criteria.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):fromBlock(string, optional): the starting block number, given as a hexadecimal string. Example: "0x1" for the first block.toBlock(string, optional): the ending block number, given as a hexadecimal string. Example: "latest" for the most recent block.fromAddress(array of strings, optional): an array of addresses that initiated the transactions. Example: ["0xAddress1", "0xAddress2"].toAddress(array of strings, optional): an array of addresses that received the transactions. Example: ["0xAddress1", "0xAddress2"].after(integer, optional): the offset for pagination. Example: 0.count(integer, optional): the number of results to return. Example: 100.topics(array of arrays of strings, optional): an array of log topics to filter by. Each inner array represents a set of possible values for that topic. Example: [["0xTopic1", "0xTopic2"], ["0xTopic3"]].
Returns
-
action(object)- For
call:callType(string): the type of call (e.g., "call", "delegatecall", "staticcall").from(string): the address that initiated the call.to(string): the address that was called.gas(string): the amount of gas provided for the call.input(string): the input data for the call.value(string): the amount of Wei sent with the call.
- For
create:from(string): the address that created the contract.gas(string): the amount of gas provided for the creation.init(string): the initialization code for the contract.value(string): the amount of Wei sent with the creation.
- For
reward:author(string): the address that received the reward.value(string): the amount of Wei rewarded.rewardType(string): the type of reward (e.g., "block", "uncle").
- For
suicide:address(string): the address of the contract that self-destructed.refundAddress(string): the address that received the remaining balance.balance(string): the remaining balance of the contract.
- For
-
blockHash(string): the hash of the block containing the transaction. -
blockNumber(string): The number of the block containing the transaction. -
result(object)- For
call:gasUsed(string): The amount of gas used by the call.output(string): The output data from the call.
- For
create:address(string): The address of the created contract.code(string): The runtime code of the created contract.gasUsed(string): The amount of gas used by the creation.
- For
reward: No additional fields. - For
suicide: No additional fields.
- For
-
subtraces(integer): The number of subtraces (nested traces) generated by this trace. -
traceAddress(array of integers): The address within the trace hierarchy. -
transactionHash(string): The hash of the transaction containing the trace. -
transactionPosition(integer): The index position of the transaction within the block. -
type(string): The type of trace (e.g., "call", "create", "reward", "suicide").
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_filter",
"params": [{
"fromBlock": "0x3ff718",
"toBlock": "0x3ff720",
"fromAddress": ["0x1234567890abcdef1234567890abcdef12345678"],
"toAddress": ["0xabcdefabcdefabcdefabcdefabcdefabcdefabcd"],
"topics": [["0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"]]
}],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": []
}
trace_transaction
Retrieves the traces created during the execution of a given transaction.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):transactionHash(string; required): the hash of the transaction for which you want to retrieve the traces.
Returns
-
action(object)- For
call:callType(string): the type of call (e.g., "call", "delegatecall", "staticcall").from(string): the address that initiated the call.to(string): the address that was called.gas(string): the amount of gas provided for the call.input(string): the input data for the call.value(string): the amount of Wei sent with the call.
- For
create:from(string): the address that created the contract.gas(string): the amount of gas provided for the creation.init(string): the initialization code for the contract.value(string): the amount of Wei sent with the creation.
- For
reward:author(string): the address that received the reward.value(string): the amount of Wei rewarded.rewardType(string): the type of reward (e.g., "block", "uncle").
- For
suicide:address(string): the address of the contract that self-destructed.refundAddress(string): the address that received the remaining balance.balance(string): the remaining balance of the contract.
- For
-
blockHash(string): the hash of the block containing the transaction. -
blockNumber(string): The number of the block containing the transaction. -
result(object)- For call:
gasUsed(string): The amount of gas used by the call.output(string): The output data from the call.
- For
create:address(string): The address of the created contract.code(string): The runtime code of the created contract.gasUsed(string): The amount of gas used by the creation.
- For
reward: No additional fields. - For
suicide: No additional fields.
- For call:
-
subtraces(integer): The number of subtraces (nested traces) generated by this trace. -
traceAddress(array of integers): The address within the trace hierarchy. -
transactionHash(string): The hash of the transaction containing the trace. -
transactionPosition(integer): The index position of the transaction within the block. -
type(string): The type of trace (e.g., "call", "create", "reward", "suicide").
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_transaction",
"params": ["0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"action": {
"callType": "call",
"from": "0x339d413ccefd986b1b3647a9cfa9cbbe70a30749",
"gas": "0x38025",
"input": "0x3161b7f60000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a50000000000000000000000000000000000000000000123a8d6d9f1c9e741075000000000000000000000000000000000000000000000000000000000017d78400000000000000000000000000000000000000000000000000000000000000010",
"value": "0x0",
"to": "0x2d61dcdd36f10b22176e0433b86f74567d529aaa"
},
"result": {
"gasUsed": "0x38025",
"output": "0x"
},
"subtraces": 1,
"traceAddress": [],
"type": "call",
"blockHash": "0xb20d0897ac3567d603afb646238b66e455bf28d234ce96cdbbe86ddc8d27c9e9",
"blockNumber": 344366750,
"transactionHash": "0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e",
"transactionPosition": 0
}
]
}
trace_replayTransaction
Replays a transaction and returns the traces produced by its execution along with the state changes.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):transactionHash(string): the hash of the transaction to be replayed.traceTypes(array of strings): the types of traces to be included in the response. Possible value:trace.
Returns
The method returns an object that can include the following fields:
-
trace(array): an array of trace objects, similar to those returned bytrace_transactionandtrace_filter:-
action(object)- For
call:callType(string): the type of call (e.g., "call", "delegatecall", "staticcall").from(string): the address that initiated the call.to(string): the address that was called.gas(string): the amount of gas provided for the call.input(string): the input data for the call.value(string): the amount of Wei sent with the call.
- For
create:from(string): the address that created the contract.gas(string): the amount of gas provided for the creation.init(string): the initialization code for the contract.value(string): the amount of Wei sent with the creation.
- For
reward:author(string): the address that received the reward.value(string): the amount of Wei rewarded.rewardType(string): the type of reward (e.g., "block", "uncle").
- For
suicide:address(string): the address of the contract that self-destructed.refundAddress(string): the address that received the remaining balance.balance(string): the remaining balance of the contract.
- For
-
blockHash(string): the hash of the block containing the transaction. -
blockNumber(string): The number of the block containing the transaction. -
result(object)- For call:
gasUsed(string): The amount of gas used by the call.output(string): The output data from the call.
- For
create:address(string): The address of the created contract.code(string): The runtime code of the created contract.gasUsed(string): The amount of gas used by the creation.
- For
reward: No additional fields. - For
suicide: No additional fields.
- For call:
-
subtraces(integer): The number of subtraces (nested traces) generated by this trace. -
traceAddress(array of integers): The address within the trace hierarchy. -
transactionHash(string): The hash of the transaction containing the trace. -
transactionPosition(integer): The index position of the transaction within the block. -
type(string): The type of trace (e.g., "call", "create", "reward", "suicide").
-
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_replayTransaction",
"params": ["0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e", ["trace"]],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"output": "0x",
"stateDiff": null,
"trace": [
{
"action": {
"callType": "call",
"from": "0x339d413ccefd986b1b3647a9cfa9cbbe70a30749",
"gas": "0x38025",
"input": "0x3161b7f60000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000a50000000000000000000000000000000000000000000123a8d6d9f1c9e741075000000000000000000000000000000000000000000000000000000000017d78400000000000000000000000000000000000000000000000000000000000000010",
"value": "0x0",
"to": "0x2d61dcdd36f10b22176e0433b86f74567d529aaa"
},
"result": {
"gasUsed": "0x38025",
"output": "0x"
},
"subtraces": 1,
"traceAddress": [],
"type": "call"
}
],
"vmTrace": null
}
}
trace_replayBlockTransactions
Replays all the transactions in a given block and returns the traces produced by their execution along with the state changes.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):blockHash(string): the hash of the block whose transactions you want to replay.traceTypes(array of strings): the types of traces to be included in the response. Possible value:trace.
Returns
The method returns an object that can include the following fields:
-
trace(array): an array of trace objects, similar to those returned bytrace_transactionandtrace_filter:-
action(object)- For
call:callType(string): the type of call (e.g., "call", "delegatecall", "staticcall").from(string): the address that initiated the call.to(string): the address that was called.gas(string): the amount of gas provided for the call.input(string): the input data for the call.value(string): the amount of Wei sent with the call.
- For
create:from(string): the address that created the contract.gas(string): the amount of gas provided for the creation.init(string): the initialization code for the contract.value(string): the amount of Wei sent with the creation.
- For
reward:author(string): the address that received the reward.value(string): the amount of Wei rewarded.rewardType(string): the type of reward (e.g., "block", "uncle").
- For
suicide:address(string): the address of the contract that self-destructed.refundAddress(string): the address that received the remaining balance.balance(string): the remaining balance of the contract.
- For
-
blockHash(string): the hash of the block containing the transaction. -
blockNumber(string): The number of the block containing the transaction. -
result(object)- For call:
gasUsed(string): The amount of gas used by the call.output(string): The output data from the call.
- For
create:address(string): The address of the created contract.code(string): The runtime code of the created contract.gasUsed(string): The amount of gas used by the creation.
- For
reward: No additional fields. - For
suicide: No additional fields.
- For call:
-
subtraces(integer): The number of subtraces (nested traces) generated by this trace. -
traceAddress(array of integers): The address within the trace hierarchy. -
transactionHash(string): The hash of the transaction containing the trace. -
transactionPosition(integer): The index position of the transaction within the block. -
type(string): The type of trace (e.g., "call", "create", "reward", "suicide").
-
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_replayBlockTransactions",
"params": ["0x58ddccddbc8d1deddf91e43e6623cdc2e1186f067dc687bb3928076a02bad39e", ["trace"]],
"id": 1
}'
trace_block
Retrieves a detailed trace of all the transactions in a specific block.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):blockNumber(string): the number of the block you want to trace, given as a hexadecimal string.
Returns
The method returns an array of trace objects, each of which contains detailed information about a particular operation. These trace objects include the following fields:
action(object): describes the action that was performed. The structure of this object varies based on the type of action.-
For
callactions:callType(string): the type of call (e.g., "call", "delegatecall", "staticcall").from(string): the address that initiated the call.to(string): the address that was called.gas(string): the amount of gas provided for the call.input(string): the input data for the call.value(string): the amount of Wei sent with the call.
-
For
createactions:from(string): the address that created the contract.gas(string): the amount of gas provided for the creation.init(string): the initialization code for the contract.value(string): the amount of Wei sent with the creation.
-
For
rewardactions:author(string): the address that received the reward.value(string): the amount of Wei rewarded.rewardType(string): the type of reward (e.g., "block", "uncle").
-
For
suicideactions:address(string): the address of the contract that self-destructed.refundAddress(string): the address that received the remaining balance.balance(string): the remaining balance of the contract.
-
blockHash(string): the hash of the block containing the transaction. -
blockNumber(string): the number of the block containing the transaction. -
result(object): describes the result of the action.-
For
callactions:gasUsed(string): the amount of gas used by the call.output(string): the output data from the call.
-
For
createactions:address(string): the address of the created contract.code(string): the runtime code of the created contract.gasUsed(string): the amount of gas used by the creation.
-
For
rewardactions: no additional fields. -
For
suicideactions: no additional fields.
-
-
subtraces(integer): the number of subtraces (nested traces) generated by this trace. -
traceAddress(array of integers): the address within the trace hierarchy, indicating the position of the trace in the call stack. -
transactionHash(string): the hash of the transaction containing the trace. -
transactionPosition(integer): the index position of the transaction within the block. -
type(string): the type of trace (e.g., "call", "create", "reward", "suicide").
-
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "trace_block",
"params": ["0x14869E9E"],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": []
}
debug_traceBlockByHash
Traces the execution of all transactions within a block specified by hash.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<blockHash>(string; required): the hash of the block you want to trace.tracer(string; optional): the tracer to use for the operation. Tracers can customize the output, for example, by including only certain types of operations. Common tracers are the following:callTracer: generates a detailed trace of all calls, including internal contract calls.callTracerhas the following parameters:onlyTopCall(boolean): iftrue, only the top-level call is traced.tracerConfig(object): additional options to customize the output, such as including or excluding specific call types.
prestateTracer: traces the state of accounts before the execution of transactions.noopTracer: a no-operation tracer that returns minimal information.fourByteTracer: identifies the function signature of calls by analyzing the first four bytes of the calldata.memoryTracer: traces memory changes during the execution of transactions.memoryTracerhas the following parameters:disableMemory(boolean): if true, memory output is omitted.
opTracer: traces all the EVM opcodes executed during a transaction.opTracerhas the following parameters:includeMemory(boolean): if true, includes memory output.includeStack(boolean): if true, includes stack output.includeStorage(boolean): if true, includes storage output.
gasTracer: traces the gas usage of the transaction and breaks it down by operation.
timeout(optional, string): sets a timeout for the tracing operation, expressed in milliseconds (e.g., "5s" for 5 seconds). If the operation exceeds this time, it will be terminated.tracingOptions(optional, object): an object to specify additional options for the trace, such as:disableMemory(boolean): if true, memory output is omitted.disableStack(boolean): if true, stack output is omitted.disableStorage(boolean): if true, storage output is omitted.
You can create custom tracers by combining existing tracer parameters or defining new ones. The flexibility of tracers allows you to tailor the debugging output to your specific needs, focusing on different aspects of transaction execution.
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "debug_traceBlockByHash",
"params": [
"0x33fae588909af0e48e0e70e799c366206d98e27a4b31c818324a5c95d5d9fe1b",
{
"tracer": "callTracer",
"timeout": "5s",
"tracingOptions": {
"disableMemory": true,
"disableStack": true,
"disableStorage": false
}
}
],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"result": {
"type": "CALL",
"from": "0x12090c459a10757e4debaa114a46c082c22bdc70",
"to": "0x8018de591a0593bf856ffcff675ad87c39b8e633",
"value": "0x3bcb33300e37dc0000",
"gas": "0x0",
"gasUsed": "0x0",
"input": "0x",
"output": "0x"
}
}
]
}
debug_traceBlockByNumber
Traces the execution of all transactions within a block specified by number.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<blockNumber>(string; hex; required): the hex number of the block you want to trace.tracer(string; optional): the tracer to use for the operation. Tracers can customize the output, for example, by including only certain types of operations. Common tracers are the following:callTracer: generates a detailed trace of all calls, including internal contract calls.callTracerhas the following parameters:onlyTopCall(boolean): iftrue, only the top-level call is traced.tracerConfig(object): additional options to customize the output, such as including or excluding specific call types.
prestateTracer: traces the state of accounts before the execution of transactions.noopTracer: a no-operation tracer that returns minimal information.fourByteTracer: identifies the function signature of calls by analyzing the first four bytes of the calldata.memoryTracer: traces memory changes during the execution of transactions.memoryTracerhas the following parameters:disableMemory(boolean): if true, memory output is omitted.
opTracer: traces all the EVM opcodes executed during a transaction.opTracerhas the following parameters:includeMemory(boolean): if true, includes memory output.includeStack(boolean): if true, includes stack output.includeStorage(boolean): if true, includes storage output.
gasTracer: traces the gas usage of the transaction and breaks it down by operation.
timeout(optional, string): sets a timeout for the tracing operation, expressed in milliseconds (e.g., "5s" for 5 seconds). If the operation exceeds this time, it will be terminated.tracingOptions(optional, object): an object to specify additional options for the trace, such as:disableMemory(boolean): if true, memory output is omitted.disableStack(boolean): if true, stack output is omitted.disableStorage(boolean): if true, storage output is omitted.
You can create custom tracers by combining existing tracer parameters or defining new ones. The flexibility of tracers allows you to tailor the debugging output to your specific needs, focusing on different aspects of transaction execution.
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "debug_traceBlockByNumber",
"params": [
"0x2A5D33",
{
"tracer": "callTracer",
"timeout": "5s",
"tracingOptions": {
"disableMemory": true,
"disableStack": true,
"disableStorage": false
}
}
],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"result": {
"type": "CALL",
"from": "0x12090c459a10757e4debaa114a46c082c22bdc70",
"to": "0x8018de591a0593bf856ffcff675ad87c39b8e633",
"value": "0x3bcb33300e37dc0000",
"gas": "0x0",
"gasUsed": "0x0",
"input": "0x",
"output": "0x"
}
}
]
}
debug_traceBlock
Traces the execution of all transactions within a block.
Parameters
-
id(integer; required): a request ID (example: 1). -
jsonrpc(string; required): a JSON RPC spec used (example: 2.0). -
method(string; required): a method used for the request. -
params(array; required):<blockRlp>(string; hex; required): the RLP-encoded data of the block you want to trace.tracer(string; optional): the tracer to use for the operation. Tracers can customize the output, for example, by including only certain types of operations. Common tracers are the following:callTracer: generates a detailed trace of all calls, including internal contract calls.callTracerhas the following parameters:onlyTopCall(boolean): iftrue, only the top-level call is traced.tracerConfig(object): additional options to customize the output, such as including or excluding specific call types.
prestateTracer: traces the state of accounts before the execution of transactions.noopTracer: a no-operation tracer that returns minimal information.fourByteTracer: identifies the function signature of calls by analyzing the first four bytes of the calldata.memoryTracer: traces memory changes during the execution of transactions.memoryTracerhas the following parameters:disableMemory(boolean): if true, memory output is omitted.
opTracer: traces all the EVM opcodes executed during a transaction.opTracerhas the following parameters:includeMemory(boolean): if true, includes memory output.includeStack(boolean): if true, includes stack output.includeStorage(boolean): if true, includes storage output.
gasTracer: traces the gas usage of the transaction and breaks it down by operation.
timeout(optional, string): sets a timeout for the tracing operation, expressed in milliseconds (e.g., "5s" for 5 seconds). If the operation exceeds this time, it will be terminated.tracingOptions(optional, object): an object to specify additional options for the trace, such as:disableMemory(boolean): if true, memory output is omitted.disableStack(boolean): if true, stack output is omitted.disableStorage(boolean): if true, storage output is omitted.
You can create custom tracers by combining existing tracer parameters or defining new ones. The flexibility of tracers allows you to tailor the debugging output to your specific needs, focusing on different aspects of transaction execution.
Request example
curl -X POST https://rpc.ankr.com/bsc/YOUR_ANKR_API_KEY \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc": "2.0",
"method": "debug_traceBlock",
"params": [
"blockRlp",
{
"tracer": "tracerType",
"timeout": "timeoutDuration",
"tracingOptions": {
"disableMemory": boolean,
"disableStack": boolean,
"disableStorage": boolean
}
}
],
"id": 1
}'
Response example
{
"jsonrpc": "2.0",
"id": 1,
"result": [
{
"type": "call",
"from": "0x1234...abcd", // Address initiating the transaction
"to": "0xabcd...1234", // Address receiving the transaction
"gas": "0x5208", // Gas provided for the transaction
"gasUsed": "0x2100", // Gas actually used during execution
"input": "0x...", // Input data to the transaction (usually calldata)
"output": "0x...", // Output data from the transaction (e.g., return data)
"value": "0x0", // Value transferred in the transaction (in wei)
"calls": [ // Nested calls (if any)
{
"type": "call",
"from": "0xabcd...1234",
"to": "0x1234...abcd",
"gas": "0x5208",
"gasUsed": "0x2100",
"input": "0x...",
"output": "0x...",
"value": "0x0"
}
]
}
]
}