Skip to content
Logo

cartesi_listEpochs

Usage

import {  } from "@cartesi/rpc";
 
const  = ({ : "http://127.0.0.1:6751/rpc" });
 
const { ,  } = await .("cartesi_listEpochs", {
    : "0x0974CC873dF893B302f6be7ecf4F9D4b1A15C366",
    : 50,
    : 0,
});

Filters

The request can filter results by:

  • status: EpochStatus | NonEmptyArray<EpochStatus> — one status, or a list of statuses combined with OR semantics. The node rejects an empty list, so the type is a non-empty array and status: [] does not compile
  • from: HexNumber — inclusive lower bound on the epoch index
  • to: HexNumber — inclusive upper bound on the epoch index
import {
    type ,
    type ,
    type ,
} from "@cartesi/rpc"

To stay in sync, keep discovery and refresh separate: advance from to the next unseen epoch index to discover new epochs, and refresh the epochs already seen by filtering them on the non-terminal statuses. Terminal statuses (CLAIM_ACCEPTED, CLAIM_REJECTED and CLAIM_FORECLOSED) never regress, so a settled epoch can be dropped from the refresh set for good:

import {  } from "@cartesi/rpc";
 
const  = ({ : "http://127.0.0.1:6751/rpc" });
 
const { :  } = await .("cartesi_listEpochs", {
    : "0x0974CC873dF893B302f6be7ecf4F9D4b1A15C366",
    : [
        "OPEN",
        "CLOSED",
        "INPUTS_PROCESSED",
        "CLAIM_COMPUTED",
        "CLAIM_SUBMITTED",
        "CLAIM_STAGED",
    ],
});

Return Type

The data is an array of Epoch:

import {
    type ,
    type ,
} from "@cartesi/rpc";

For more information about pagination refer to the pagination section.