Filecoin.ChainGetTipSetByHeight - Filecoin

This method returns the tipset at a given epoch. If the requested epoch has no blocks (a null round), the nearest earlier non-empty tipset is returned.

Parameters

ParameterTypeRequiredDescription
epochintegerYesThe chain epoch (height) to retrieve
tipsetKeyarrayYesTipset key to read from; empty array for the chain head

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.ChainGetTipSetByHeight", "params": [4523800, []], "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.ChainGetTipSetByHeight',
        params: [4523800, []],
        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.ChainGetTipSetByHeight',
        'params': [4523800, []],
        'id': 'getblock.io'
    }
)

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

Response

json{
    "jsonrpc": "2.0",
    "id": "getblock.io",
    "result": {
        "Cids": [
            {
                "/": "bafy2bzacecdkonmhngylnnhrk4azkg2wkgcm6cnm5qn5sk4ww5cszjlvkgkd6"
            }
        ],
        "Blocks": [
            {
                "Miner": "f01234",
                "Height": 4523800
            }
        ],
        "Height": 4523800
    }
}

Response Parameters

FieldTypeDescription
CidsarrayCIDs of the blocks in the tipset
BlocksarrayBlock headers of the tipset
HeightintegerEpoch of the returned tipset

Use Cases

  • Historical Reads: Resolve a tipset at a specific epoch
  • Block Indexing: Walk the chain epoch by epoch
  • Null Round Handling: Get the nearest tipset when an epoch is empty
  • Snapshotting: Pin a tipset key for consistent state queries

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