Skip to main content

JSON-RPC

Bitlayer provides all JSON-RPC API methods listed on Ethereum , but currently with eth_feeHistory disabled. Because there's some issue for Metamask users when priority fee per gas is less than 1 gwei, and we want to avoid our users spending unnecessary high fee.

If you rely on eth_feeHistory, you can try eth_feeHistory2 instead.

And besides, Bitlayer added several custom methods as follows.

eth_getTraceActionByTxHash

This method returns logs of internal transactions by the hash of a transaction.

Parameters

  • DATA, 32 Bytes: Hash of a transaction.
  • Object: Filter options:
    • fromUser: DATA|Array, 20 Bytes (optional) - Address of the sender.
    • toBlock: DATA|Array, 20 Bytes (optional) - Address of the receiver.
    • opCode: String (optional) - An EVM opcode for a transaction's log.
    • minValue: QUANTITY|TAG (optional) - The minimal value or amount transferred in BRC.

Returns

An object containing an internal transaction's log, or null if no log was found:

  • transactionHash: DATA, 32 Bytes - Hash of the transaction.
  • blockHash: DATA, 32 Bytes - Hash of the block (null if pending).
  • blockNumber: QUANTITY - Block number of the transaction.
  • logs: Array of log objects generated by the transaction:
    • from: DATA, 20 Bytes - Address of the sender.
    • to: DATA, 20 Bytes - Address of the receiver (null if it's a contract creation transaction).
    • value: QUANTITY - Value transferred in BRC.
    • success: Boolean - Indicates whether the call was successful.
    • opcode: DATA - The EVM opcode of the transaction's log.
    • depth: QUANTITY - The depth of the call stack in EVM.
    • gas: QUANTITY - Gas provided by the sender.
    • gas_used: QUANTITY - Amount of gas used by the transaction.
    • input: DATA - Data sent along with the transaction.
    • trace_address: QUANTITY|Array - Array representing the call trace depth during execution.

Example

Request:

curl -X POST --data '{  "jsonrpc":"2.0",  "method":"eth_getTraceActionByTxHash",  "params":["0xce9a42b2d2e0c0a7984d9351793129b91dc0599b9b4401082b75afcbc6abd694"], "id":1}'

Response:

{
"id": 1,
"jsonrpc": "2.0",
"result": [
{
"transactionHash": "0xce9a42b2d2e0c0a7984d9351793129b91dc0599b9b4401082b75afcbc6abd694",
"blockHash": "0x80f5779b0348102d90f5463a9a494b7454d0e1f8d8b119cf090cd90e2d6105c3",
"blockNumber": 54,
"logs": [
{
"from": "0x2e46771cff3636a42f363826ff8a94d3a738e075",
"to": "0x000000000000000000000000000000000000f000",
"value": 0,
"success": true,
"opcode": "CALL",
"depth": 18446744073709551615,
"gas": 165629,
"gas_used": 162996,
"input": "0x6374299e0000000000000000000000009f01eb5eb4dbea8b2cecc679050819990ab68a1a000000000000000000000000000000000000000000295be96e64066972000000",
"trace_address": []
},
{
"from": "0x000000000000000000000000000000000000f000",
"to": "0x4b20bbf3652696b9afd27b8f88ff8b7c1f361336",
"value": 0,
"success": true,
"opcode": "STATICCALL",
"depth": 0,
"gas": 157800,
"gas_used": 2443,
"input": "0x00000000",
"output": "0x0000000000000000000000002e46771cff3636a42f363826ff8a94d3a738e075",
"trace_address": [
0
]
},
{
"from": "0x000000000000000000000000000000000000f000",
"to": "0xf4340cf5f3891a3827713b33f769b501a0b5b122",
"value": 0,
"success": true,
"opcode": "STATICCALL",
"depth": 0,
"gas": 150040,
"gas_used": 2814,
"input": "0x0000000000000000000000000000000000000000007c13bc4b2c133c560000000000000000000000000000000000000000000000007c13bc4b2c133c5600000000000000",
"output": "0x0000000000000000000000000000000000000000007c13bc4b2c133c56000000",
"trace_address": [
1
]
}
]
}
]
}

eth_getTraceActionByBlockNumber

Returns logs of internal transactions by block number.

Parameters

  1. QUANTITY|TAG - integer of a block number

  2. Object - The filter options:

    • fromUser: DATA|Array, 20 Bytes - (optional) address of the sender.
    • toBlock: DATA|Array, 20 Bytes - (optional) address of the receiver.
    • opCode: String - (optional) An EVM opcode for a transaction's log.
    • minValue: QUANTITY|TAG - (optional) the minimal value or amount transferred in BRC.

Returns

Same as eth_getTraceActionByTxHash

Example

Request:

curl -X POST --data '{  "jsonrpc":"2.0",  "method":"eth_getTraceActionByBlockNumber",  "params":["0x36"],  "id":1}'

Result see eth_getTraceActionByTxHash

eth_getTraceActionByBlockHash

Returns logs of internal transactions by block hash.

Parameters

  1. DATA, 32 Bytes - Hash of a block.

Returns

Same as eth_getTraceActionByTxHash

Example

Request:

curl -X POST --data '{  "jsonrpc":"2.0",  "method":"eth_getTraceActionByBlockHash",  "params":["0x80f5779b0348102d90f5463a9a494b7454d0e1f8d8b119cf090cd90e2d6105c3"],  "id":1}'

Result see eth_getTraceActionByTxHash