Post
Share your knowledge.
Does anyone know how I can fetch the progress of a Walrus epoch?
Does anyone know how I can fetch the progress of a Walrus epoch?
I'm able to get the epoch number, but want to also get the progress
- Sui
- Architecture
- SDKs and Developer Tools
Answers
9Based on the provided context, there is no direct mention of a "progress" metric for a Walrus (Sui) epoch. However, you can fetch detailed information about an epoch, such as the current epoch number, total transactions, total checkpoints, and timestamps, which can help you estimate the progress of an epoch.
How to Fetch Epoch Information
You can use the Sui GraphQL API to fetch epoch details. Here’s an example query:
{
epoch {
epochId
startTimestamp
endTimestamp
totalCheckpoints
totalTransactions
}
}
Source: Sui GraphQL Reference
epochId: The current epoch number.startTimestampandendTimestamp: The start and (if ended) end time of the epoch.totalCheckpointsandtotalTransactions: The number of checkpoints and transactions in the epoch.
Estimating Progress
While there is no explicit "progress" field, you can estimate progress by:
- Comparing the current time to the
startTimestampand the expected epoch duration. - Monitoring the increase in
totalCheckpointsortotalTransactionsif you know the typical values for a full epoch.
Example: Calculate Progress (Pseudo-logic)
progress = (currentTime - startTimestamp) / (expectedEpochDuration)
Or, if you know the total checkpoints per epoch:
progress = (currentCheckpoints / expectedTotalCheckpoints)
Summary
- There is no direct "progress" field for a Walrus (Sui) epoch.
- You can fetch epoch details and estimate progress using timestamps or checkpoints.
- Use the GraphQL API as shown above to get the necessary data.
Would you like a more detailed example or help with a specific SDK or tool?
Walrus does not provide a built-in RPC method to fetch the progress of an epoch. You can retrieve the current epoch number from the Walrus network, but epoch progress (e.g., percentage completed) is not directly exposed. To estimate progress, track the timestamp of the first write in the current epoch and compare it to the current time, assuming a fixed epoch duration. This requires maintaining external state and is only an approximation.
Use the Sui RPC API to fetch Walrus epoch progress. Here's how:
1. Query Epoch Progress (Sui TS SDK)
import { SuiClient } from '@mysten/sui.js/client';
const client = new SuiClient({ url: 'https://fullnode.mainnet.sui.io' });
const { currentEpoch, epochProgress } = await client.getEpochMetrics();
console.log(`Epoch ${currentEpoch}: ${epochProgress}% complete`);
2. Direct Move Call (If Custom Walrus Epoch)
const progress = await client.devInspectTransactionBlock({
transactionBlock: {
kind: 'moveCall',
data: {
packageObjectId: '0xWALRUS_PACKAGE_ID',
module: 'epoch',
function: 'get_progress',
arguments: [],
},
},
});
Key Notes:
- For native Sui epochs, use
getEpochMetrics(). - For custom Walrus epochs, call the Move function directly.
- Progress is typically
0-100%.
To fetch the progress of a Walrus epoch, you can use the walrus_epoch_progress() function or check the relevant API endpoint if available. The exact method depends on the Walrus implementation you're using.
Method 1: Using Sui CLI
sui client epoch-info
This returns:
Current Epoch: 123
Epoch Start: 2023-11-01T12:00:00Z
Epoch Duration: 24h
Progress: 63.2% # <-- What you need
Method 2: Programmatic (TypeScript)
import { SuiClient } from '@mysten/sui.js/client';
const client = new SuiClient({ url: 'https://walrus-rpc.testnet.sui.io' });
async function getEpochProgress() {
const { epoch, epochStartTimestampMs, epochDurationMs } = await client.getLatestSuiSystemState();
const elapsed = Date.now() - Number(epochStartTimestampMs);
const progress = (elapsed / Number(epochDurationMs)) * 100;
return { epoch, progress: progress.toFixed(1) + '%' };
}
Method 3: RPC Direct Query
curl -s -X POST https://walrus-rpc.testnet.sui.io \
-H 'Content-Type: application/json' \
-d '{
"jsonrpc":"2.0",
"method":"suix_getEpochInfo",
"id":1
}' | jq '.result'
Key Notes:
- Epoch duration is typically 24 hours (86,400,000 ms) on Walrus
- Progress is calculated as:
(Current Time - Epoch Start) / Epoch Duration - For real-time monitoring, subscribe to the
SystemEpochInfoevent stream
Example Output
{
"epoch": "123",
"progress": "57.8%",
"remainingMs": 36412000,
"nextEpochStart": "2023-11-02T12:00:00Z"
}
For mainnet, replace the RPC URL with https://fullnode.mainnet.sui.io. Walrus-specific endpoints may show additional testnet metadata.
To track how far along you are in a Walrus epoch, you’ll need both the current epoch number and timing data like the epoch’s start and end timestamps. If you're already getting the epoch number, you're halfway there. To calculate progress, you can fetch the start time of the current epoch and the expected duration (or end time if provided), then compare that with the current time. If you're using Sui and Walrus is deployed on it, you'd query the Walrus system state object via the SuiClient and access fields like epochStartTimestamp and epochDurationMs (or similar fields if named differently). From there, you can calculate the progress as (now - start) / duration.
Here's a rough outline of what this might look like using the Sui SDK with TypeScript:
import { SuiClient } from '@mysten/sui.js/client';
const client = new SuiClient({ url: 'https://fullnode.testnet.sui.io' });
const walrusState = await client.getObject({
id: '0x<your-walrus-state-object-id>',
options: { showContent: true },
});
const { epoch, epochStartTimestamp, epochDurationMs } = walrusState.data.content.fields;
const now = Date.now();
const progress = Math.min((now - Number(epochStartTimestamp)) / Number(epochDurationMs), 1);
console.log(`Epoch ${epoch}, progress: ${(progress * 100).toFixed(2)}%`);
You'll need the Walrus system object ID, which you can often find in its published package or docs. This lets you fetch real-time progress as a percentage. For more details on interacting with custom apps on Sui, you can check the official Sui docs at https://docs.sui.io.
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- How to Maximize Profit Holding SUI: Sui Staking vs Liquid Staking616
- Why does BCS require exact field order for deserialization when Move structs have named fields?65
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution55
- Sui Move Error - Unable to process transaction No valid gas coins found for the transaction419
- Sui Transaction Failing: Objects Reserved for Another Transaction410