LedgerService.GetEpoch
Get epoch through sui.rpc.v2.LedgerService/GetEpoch on Inodra's Sui gRPC endpoint.
Endpoint
| Network | Host | Authentication |
|---|---|---|
| Mainnet | mainnet-grpc.inodra.com:443 | x-api-key metadata |
| Testnet | testnet-grpc.inodra.com:443 | x-api-key metadata |
Full method name: sui.rpc.v2.LedgerService/GetEpoch. Unary: one request, one response. Get a key from the dashboard; the same key works on every protocol.
Request: GetEpochRequest
| Field | Type | Description |
|---|---|---|
epoch | uint64 | The requested epoch. If no epoch is provided the current epoch will be returned. |
read_mask | google.protobuf.FieldMask | Mask specifying which fields to read. If no mask is specified, defaults to epoch. |
Response: GetEpochResponse
| Field | Type | Description |
|---|---|---|
epoch | Epoch |
Epoch
| Field | Type | Description |
|---|---|---|
epoch | uint64 | |
committee | ValidatorCommittee | The committee governing this epoch. |
system_state | SystemState | Snapshot of Sui's SystemState (0x3::sui_system::SystemState) at the beginning of the epoch, for past epochs, or the current state for the current epoch. |
first_checkpoint | uint64 | |
last_checkpoint | uint64 | |
start | google.protobuf.Timestamp | |
end | google.protobuf.Timestamp | |
reference_gas_price | uint64 | Reference gas price denominated in MIST |
protocol_config | ProtocolConfig |
grpcurl
grpcurl -H "x-api-key: YOUR_API_KEY" \
-d '{
"read_mask": {
"paths": [
"epoch"
]
}
}' \
mainnet-grpc.inodra.com:443 \
sui.rpc.v2.LedgerService/GetEpochServer reflection is enabled, so no proto files are needed for grpcurl. Field masks are written as {"paths": [...]}.
TypeScript
import { GrpcWebFetchTransport, SuiGrpcClient } from '@mysten/sui/grpc'
const transport = new GrpcWebFetchTransport({
baseUrl: 'https://mainnet-grpc.inodra.com',
meta: { 'x-api-key': process.env.INODRA_API_KEY! }
})
const client = new SuiGrpcClient({ network: 'mainnet', transport })
// No epoch: returns the current epoch
const { response } = await client.ledgerService.getEpoch({
readMask: { paths: ['epoch', 'reference_gas_price'] }
})
console.log(response.epoch?.epoch, response.epoch?.referenceGasPrice)@mysten/sui v2 has no typed method for this RPC, so the sample calls the generated client.ledgerService service client. Install with npm install @mysten/sui and set INODRA_API_KEY. The gRPC gateway guide covers native gRPC transport for backends.
Credits
1 credit per call. Reads served from the archival tier cost 2x; the response metadata carries x-inodra-backend naming the tier that answered. See credits and billing for the full table.
Related
- LedgerService overview and the gRPC gateway
- LedgerService.GetServiceInfo
- LedgerService.GetObject
- LedgerService.BatchGetObjects
- LedgerService.GetTransaction
- LedgerService.BatchGetTransactions
- LedgerService.GetCheckpoint
- LedgerService.ListCheckpoints
- LedgerService.ListTransactions
- LedgerService.ListEvents
- Proto definition on GitHub