cfx_getBlockByBlockNumber
Returns block with given block number.
- CURL
curl --request POST \
     --url https://main.confluxrpc.com \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "params": ["0x0",false],
  "method": "cfx_getBlockByBlockNumber"
}'
Params
block_number required
Schema
type : string
Pattern : 
^0x([1-9a-f][0-9a-f]{0,15}|0)$include_txs required
Schema
type : boolean
Result
Schema
type : object
- adaptive adaptivetype : boolean
- baseFeePerGas baseFeePerGastype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- blame blametype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,15}|0)$
- blockNumber blockNumbertype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- custom customtype : array- items[x]Bytestype : stringPattern :- ^0x[0-9a-f]*$
 
- deferredLogsBloomHash deferredLogsBloomHashtype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- deferredReceiptsRoot deferredReceiptsRoottype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- deferredStateRoot deferredStateRoottype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- difficulty difficultytype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- epochNumber epochNumbertype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- gasLimit gasLimittype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- gasUsed gasUsedtype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- hash hashtype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- height heighttype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- miner minertype : stringPattern :- ^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
- nonce noncetype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- parentHash parentHashtype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- posReference posReferencetype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- powQuality powQualitytype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- refereeHashes refereeHashestype : array- items[x]H256type : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
 
- size sizetype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- timestamp timestamptype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- transactions transactionsoneOf- (H256,...)[]
- (Transaction,...)[]
 type : array- items[x]H256type : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
 type : array- items[x]Transactiontype : object- accessList accessListtype : array- items[x]CfxAccessListItemtype : object- address addresstype : stringPattern :- ^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
- storageKeys storageKeystype : array- items[x]H256type : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
 
 
 
- blockHash blockHashtype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- chainId chainIdtype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- contractCreated contractCreatedtype : stringPattern :- ^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
- data datatype : stringPattern :- ^0x[0-9a-f]*$
- epochHeight epochHeighttype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- from fromtype : stringPattern :- ^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
- gas gastype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- gasPrice gasPricetype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- hash hashtype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
- maxFeePerGas maxFeePerGastype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- maxPriorityFeePerGas maxPriorityFeePerGastype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- nonce noncetype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- r rtype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- s stype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- space spacetype : stringPossible values :- native
- ethereum
 
- status statustype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,15}|0)$
- storageLimit storageLimittype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- to totype : stringPattern :- ^(NET\d+|CFX|CFXTEST)(:TYPE\..*|):[ABCDEFGHJKMNPRSTUVWXYZ0123456789]{42}$
- transactionIndex transactionIndextype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,15}|0)$
- transactionType transactionTypetype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,15}|0)$
- v vtype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- value valuetype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,63}|0)$
- yParity yParitytype : stringPattern :- ^0x([1-9a-f][0-9a-f]{0,15}|0)$
 
 
- transactionsRoot transactionsRoottype : stringPattern :- ^0x[0-9,a-f,A-F]{64}$
Examples
- cfx_getBlockByBlockNumber
- cfx_getBlockByBlockNumber
- cfx_getBlockByBlockNumber
- cfx_getBlockByBlockNumber
- cfx_getBlockByBlockNumber
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getBlockByBlockNumber",
    "params": [
        "0x0"
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
null
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getBlockByBlockNumber",
    "params": [
        "0x100"
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
  "adaptive": false,
  "baseFeePerGas": "0x3b9aca00",
  "blame": "0x0",
  "blockNumber": "0x100",
  "custom": [],
  "deferredLogsBloomHash": "0xd397b3b043d87fcd6fad1291ff0bfd16401c274896d8c63a923727f077b8e0b5",
  "deferredReceiptsRoot": "0x12af19d53c378426ebe08ad33e48caf3efdaaade0994770c161c0637e65a6566",
  "deferredStateRoot": "0x876e9208267ce87cb36549d55c936658dd6ca6ef76f9a84b2a24570f0dd01724",
  "difficulty": "0x4c4b40",
  "epochNumber": "0x47",
  "gasLimit": "0x1c9c380",
  "gasUsed": "0x0",
  "hash": "0x7b02db101c3cf00c4f7eb80de5a550ba55ed48ade9cd01b2cf66215a79ccc5f1",
  "height": "0x46",
  "miner": "CFXTEST:TYPE.USER:AAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA65R5HPNB",
  "nonce": "0x214b5b140a9e8330",
  "parentHash": "0xa47ae56442d4e0372c98d4ef8c3a189421c1c55ef7a9f7d2090d978530da6d46",
  "posReference": null,
  "powQuality": "0x6692de",
  "refereeHashes": [],
  "size": "0x0",
  "timestamp": "0x5f9bc2ea",
  "transactions": [],
  "transactionsRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
}
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getBlockByBlockNumber",
    "params": [
        "0x100",
        true
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
  "adaptive": false,
  "baseFeePerGas": "0x3b9aca00",
  "blame": "0x0",
  "blockNumber": "0x100",
  "custom": [],
  "deferredLogsBloomHash": "0xd397b3b043d87fcd6fad1291ff0bfd16401c274896d8c63a923727f077b8e0b5",
  "deferredReceiptsRoot": "0x12af19d53c378426ebe08ad33e48caf3efdaaade0994770c161c0637e65a6566",
  "deferredStateRoot": "0x876e9208267ce87cb36549d55c936658dd6ca6ef76f9a84b2a24570f0dd01724",
  "difficulty": "0x4c4b40",
  "epochNumber": "0x47",
  "gasLimit": "0x1c9c380",
  "gasUsed": "0x0",
  "hash": "0x7b02db101c3cf00c4f7eb80de5a550ba55ed48ade9cd01b2cf66215a79ccc5f1",
  "height": "0x46",
  "miner": "CFXTEST:TYPE.USER:AAJAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA65R5HPNB",
  "nonce": "0x214b5b140a9e8330",
  "parentHash": "0xa47ae56442d4e0372c98d4ef8c3a189421c1c55ef7a9f7d2090d978530da6d46",
  "posReference": null,
  "powQuality": "0x6692de",
  "refereeHashes": [],
  "size": "0x0",
  "timestamp": "0x5f9bc2ea",
  "transactions": [],
  "transactionsRoot": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
}
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getBlockByBlockNumber",
    "params": [
        "0x11111111111111"
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
null
Request
curl -X POST --data \
'{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "cfx_getBlockByBlockNumber",
    "params": [
        "0x11111111111111111"
    ]
}' \
-H "Content-Type: application/json" \
localhost:12539
Response
{
  "code": -32602,
  "message": "Invalid params: invalid length 17, expected a (both 0x-prefixed or not) hex string with length between (0; 16]."
}