2

Question on using the Substrate Sidecar API. I'm trying to get the current "era" a block is in. Looking through the API endpoints it's not clear which one would give me that. The "blocks/head" endpoint has an "era" field however it's only for extrinsics and their life span. I'm looking for something like how this website displays it. Any ideas?

1 Answer 1

4

You can find the documentation for all Substrate API Sidecar endpoints here.

For the information you're looking for, you can use the /pallets/staking/progress endpoint. By default, this will look up the latest block, but you can also pass in a historical block as a query param ...?at=<blockNumber>. The value you are looking for will be found in the "activeEra" key.

Here is a snipped example of the object returned from /pallets/staking/progress?at=11000000:

{
    "at": {
        "hash": "0x7fae32d478e996a90f0cad3ce0ac4b642b6d794c394bec0de4b9a10038fc924a",
        "height": "11000000"
    },
    "activeEra": "761", <--- What you're looking for

   /*-SNIP-*/
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.