Filecoin.ChainGetBlock - Filecoin

This method returns the block header for a given block CID, including its miner, parents, height, and message roots.

Parameters

ParameterTypeRequiredDescription
cidobjectYesBlock CID, as an object with a / key

Request

bashcurl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{"jsonrpc": "2.0", "method": "Filecoin.ChainGetBlock", "params": [{"/": "bafy2bzacecdkonmhngylnnhrk4azkg2wkgcm6cnm5qn5sk4ww5cszjlvkgkd6"}], "id": "getblock.io"}'

example.js

javascriptconst response = await fetch('https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
        jsonrpc: '2.0',
        method: 'Filecoin.ChainGetBlock',
        params: [{"/": "bafy2bzacecdkonmhngylnnhrk4azkg2wkgcm6cnm5qn5sk4ww5cszjlvkgkd6"}],
        id: 'getblock.io'
    })
});

const data = await response.json();
console.log(data.result);

example.py

pythonimport requests

response = requests.post(
    'https://shared.eu-central-1.getblock.io/<ACCESS-TOKEN>/',
    headers={'Content-Type': 'application/json'},
    json={
        'jsonrpc': '2.0',
        'method': 'Filecoin.ChainGetBlock',
        'params': [{"/": "bafy2bzacecdkonmhngylnnhrk4azkg2wkgcm6cnm5qn5sk4ww5cszjlvkgkd6"}],
        'id': 'getblock.io'
    }
)

print(response.json()['result'])

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "Miner": "f01234",
        "Height": 4523891,
        "ParentWeight": "123456789",
        "Parents": [
            {
                "/": "bafy2bzaceaglcpzhd5gfrzdyt7ce3e5asnbfz3s3stbqyxniziny5snewbpbg"
            }
        ],
        "ParentStateRoot": {
            "/": "bafy2bzaceaglcpzhd5gfrzdyt7ce3e5asnbfz3s3stbqyxniziny5snewbpbg"
        },
        "Messages": {
            "/": "bafy2bzacea3wsdh6y3a36tb3skempjoxqpuyompjbmfeyf34fi3uy6uue42v4"
        },
        "Timestamp": 1719400000
    }
}

Response Parameters

FieldTypeDescription
MinerstringAddress of the miner that produced the block
HeightintegerEpoch of the block
ParentsarrayCIDs of the parent tipset's blocks
ParentStateRootobjectCID of the parent state root
MessagesobjectCID of the block's message root
TimestampintegerUnix timestamp of the block

Use Cases

  • Block Explorers: Render a block header by CID
  • Chain Traversal: Follow parent CIDs up the chain
  • State Roots: Read the parent state root for state queries
  • Producer Analytics: Attribute blocks to miners

Error Handling

Error CodeMessageDescription
-32602Invalid paramsA parameter is missing or has the wrong type or format
1Actor not foundThe address or actor does not exist in the requested tipset
-32603Internal errorThe node failed to process the request