[Block] klay_getBlockByNumber
Returns information about a block by block number. This API works only on RPC call, not on JavaScript console.
NOTE: In versions earlier than Klaytn v1.7.0, only integer block number, the string "earliest" and "latest" are available.
JSONRPC: klay_getBlockByNumber
Request
- application/json
Body
Array [
- IntegerBlockNumber
- HexadecimalBlockNumber
- BlockTag
]
Default value: klay_getBlockByNumber
Method name
Default value: 1
Request ID, Random or Auto incrementation
Default value: 2.0
JSON-RPC Version (2.0)
params
undefined[]
required
BlockNumberOrTag
object
oneOf
number
string
string
If true it returns the full transaction objects, if false only the hashes of the transactions.
Responses
- 200
Returns information about a block by block number.
- application/json
- Schema
- Example (from schema)
Schema
Array [
- MOD1
- MOD2
]
Default value: 2.0
error
object
A Number that indicates the error type that occurred. This MUST be an integer.
| code | message | description | |-----|-----|-------| | -32700 | Parse error | invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. | |-32602 | Invalid params | Invalid method parameter(s). |
A String providing a short description of the error. The message SHOULD be limited to a concise single sentence.
A Primitive or Structured value that contains additional information about the error. This may be omitted. The value of this member is defined by the Server (e.g. detailed error information, nested errors etc.).
result
object
A block object, or error when no block was found
The block number. null when it is pending block.
Hash of the block. null when it is pending block.
Hash of the parent block.
The bloom filter for the logs of the block. null when it is pending block.
The root of the transaction trie of the block.
The root of the final state trie of the block.
The root of the receipts trie of the block.
The address of the beneficiary to whom the block rewards were given.
Former difficulty. Always 1 in the BFT consensus engine
Integer of the total blockScore of the chain until this block.
The "extra data" field of this block.
Integer the size of this block in bytes.
The total used gas by all transactions in this block.
The unix timestamp for when the block was collated.
The fraction of a second of the timestamp for when the block was collated.
transactions
object[]
required
Array of transaction objects, or 32-byte transaction hashes depending on the last given parameter.
oneOf
string
Hash of the transaction.
RLP encoded governance configuration
RLP encoded governance vote of the proposer
The base fee per gas. It has a meaningful value when EthTxTypeCompatible and Magma hardforks are activated.
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": -32700,
"message": "Parse error",
"data": "string"
},
"result": {
"baseFeePerGas": "0x0",
"blockscore": "0x1",
"extraData": "0xda83010800846b6c617989676f312e31362e31338664617277696e0000000000f89ed5949712f943b296758aaae79944ec975884188d3a96b841ddfdf7e2cb0a93538f757f87f23a93ee35df703c781c6f15e31e4978ecdfb3501fc00924372b9a01df2bc452f2a924c242d83580183d131c47e49a25b78f625201f843b841b9b6034d5a8c5f5b057274cda4f427614cd1f448ee781f4c4322861d1361d09d47d6030f2b69a26cb426db984f54e71f8c112fbf882930ccd715d595e8d8307500",
"gasUsed": "0x0",
"governanceData": "0x",
"hash": "0xe882d7a16f38126dc0c507f990b3fe18fa2d3a380002538581327abe96ca6edc",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"number": "0x1e67",
"parentHash": "0x28b1c054346c3bd083741c757a750dcabf94b6d50c7f87158753544e96e73550",
"receiptsRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"reward": "0x4b2c736fd05c2e2da3ccbd001a395a444f16a861",
"size": "0x272",
"stateRoot": "0xdf9885621c9e6e75912ca94d6987bcb1b54fef0e4a99cbec5e68f1ffc7468a78",
"timestamp": "0x62130beb",
"timestampFoS": "0x0",
"totalBlockScore": "0x1e68",
"transactions": [],
"transactionsRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470",
"voteData": "0x"
}
}