rollup_getInfo
Returns comprehensive information about the Optimism rollup, including sequencer status, batch submission details, and rollup configuration.
When to Use This Method
rollup_getInfo
is essential for:
- Rollup Monitoring - Check the health and status of the Optimism network
- Sequencer Status - Monitor sequencer uptime and performance
- Batch Tracking - Track L1 batch submissions and confirmations
- Network Analytics - Gather data for Optimism network analysis
- Integration Health Checks - Verify rollup parameters for applications
Parameters
None. This method takes no parameters.
Implementation Examples
- cURL
- JavaScript
curl -X POST https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "rollup_getInfo",
"params": [],
"id": 1
}'
// Get Optimism rollup information
const response = await fetch('https://api-optimism-mainnet-archive.n.dwellir.com/YOUR_API_KEY', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'rollup_getInfo',
params: [],
id: 1
})
});
const data = await response.json();
const rollupInfo = data.result;
console.log('Optimism Rollup Info:');
console.log('Mode:', rollupInfo.mode);
console.log('Sequencer Running:', rollupInfo.sequencer_running);
console.log('Synced L1 Block:', rollupInfo.synced_l1);
console.log('Head L1 Block:', rollupInfo.head_l1);
console.log('Safe L2 Block:', rollupInfo.safe_l2);
console.log('Finalized L2 Block:', rollupInfo.finalized_l2);
// Monitor rollup health
async function monitorOptimismHealth() {
const info = await getRollupInfo();
const health = {
sequencerActive: info.sequencer_running,
syncStatus: calculateSyncStatus(info),
lastBatchTime: info.last_batch_time,
l1HeadAge: Date.now() / 1000 - info.head_l1?.timestamp || 0
};
// Alert if sequencer is down
if (!health.sequencerActive) {
console.warn('⚠️ Optimism sequencer is not running!');
}
// Alert if sync is behind
if (health.syncStatus < 0.99) {
console.warn(`⚠️ Optimism sync behind: ${(health.syncStatus * 100).toFixed(2)}%`);
}
return health;
}
function calculateSyncStatus(info) {
if (!info.synced_l1 || !info.head_l1) return 0;
return info.synced_l1.block_number / info.head_l1.block_number;
}
Response Example
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"mode": "sequencer",
"sequencer_running": true,
"synced_l1": {
"block_number": 18500000,
"block_hash": "0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"timestamp": 1699123456
},
"head_l1": {
"block_number": 18500010,
"block_hash": "0xabcdef1234567890abcdef1234567890abcdef1234567890abcdef1234567890",
"timestamp": 1699123576
},
"safe_l2": {
"block_number": 123456789,
"block_hash": "0x9876543210fedcba9876543210fedcba9876543210fedcba9876543210fedcba",
"timestamp": 1699123500
},
"finalized_l2": {
"block_number": 123456700,
"block_hash": "0x456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123",
"timestamp": 1699123400
},
"unsafe_l2": {
"block_number": 123456800,
"block_hash": "0xfedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210",
"timestamp": 1699123550
}
}
}
Understanding Rollup Information
Key Fields Explained
- mode: Operating mode of the node ("sequencer", "verifier", etc.)
- sequencer_running: Whether the sequencer is actively processing transactions
- synced_l1: Last L1 block that has been processed by the rollup
- head_l1: Latest known L1 block
- safe_l2: L2 block that is considered safe (confirmed on L1)
- finalized_l2: L2 block that is finalized (cannot be reverted)
- unsafe_l2: Latest L2 block (may not be confirmed on L1 yet)
Rollup Health Monitoring
class OptimismRollupMonitor {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseUrl = `https://api-optimism-mainnet-archive.n.dwellir.com/${apiKey}`;
}
async getRollupInfo() {
const response = await fetch(this.baseUrl, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: '2.0',
method: 'rollup_getInfo',
params: [],
id: 1
})
});
return (await response.json()).result;
}
async checkRollupHealth() {
const info = await this.getRollupInfo();
const now = Math.floor(Date.now() / 1000);
const health = {
overall: 'healthy',
checks: {
sequencerActive: {
status: info.sequencer_running ? 'pass' : 'fail',
message: info.sequencer_running ? 'Sequencer is running' : 'Sequencer is down'
},
l1Sync: {
status: 'unknown',
message: 'L1 sync status'
},
l2Progress: {
status: 'unknown',
message: 'L2 block progression'
}
}
};
// Check L1 sync status
if (info.synced_l1 && info.head_l1) {
const syncRatio = info.synced_l1.block_number / info.head_l1.block_number;
health.checks.l1Sync.status = syncRatio > 0.99 ? 'pass' : 'warn';
health.checks.l1Sync.message = `Synced ${(syncRatio * 100).toFixed(2)}% of L1 blocks`;
}
// Check L2 block times
if (info.unsafe_l2) {
const blockAge = now - info.unsafe_l2.timestamp;
health.checks.l2Progress.status = blockAge < 60 ? 'pass' : 'warn';
health.checks.l2Progress.message = `Latest L2 block is ${blockAge}s old`;
}
// Determine overall health
const failedChecks = Object.values(health.checks).filter(c => c.status === 'fail').length;
const warnChecks = Object.values(health.checks).filter(c => c.status === 'warn').length;
if (failedChecks > 0) {
health.overall = 'unhealthy';
} else if (warnChecks > 0) {
health.overall = 'degraded';
}
return health;
}
async monitorContinuously(interval = 30000) {
console.log('🔍 Starting Optimism rollup monitoring...');
setInterval(async () => {
try {
const health = await this.checkRollupHealth();
const timestamp = new Date().toISOString();
console.log(`[${timestamp}] Rollup Health: ${health.overall.toUpperCase()}`);
Object.entries(health.checks).forEach(([check, result]) => {
const icon = result.status === 'pass' ? '✅' :
result.status === 'warn' ? '⚠️' : '❌';
console.log(` ${icon} ${check}: ${result.message}`);
});
if (health.overall !== 'healthy') {
console.log(`🚨 ALERT: Optimism rollup is ${health.overall}`);
}
} catch (error) {
console.error('Failed to check rollup health:', error);
}
}, interval);
}
}
// Usage
const monitor = new OptimismRollupMonitor('YOUR_API_KEY');
monitor.monitorContinuously(30000); // Check every 30 seconds
Batch Submission Tracking
// Track L1 batch submissions
class OptimismBatchTracker {
async trackBatchSubmissions() {
const info = await this.getRollupInfo();
return {
lastL2Block: info.safe_l2?.block_number || 0,
lastL1Confirmation: info.synced_l1?.block_number || 0,
pendingBlocks: (info.unsafe_l2?.block_number || 0) - (info.safe_l2?.block_number || 0),
estimatedConfirmationTime: this.estimateConfirmationTime(info)
};
}
estimateConfirmationTime(info) {
// Optimism typically submits batches every ~10-20 minutes
// Plus ~12 minutes for L1 confirmations
const avgBatchInterval = 15 * 60; // 15 minutes
const l1ConfirmationTime = 12 * 60; // 12 minutes
return avgBatchInterval + l1ConfirmationTime;
}
}
Need help? Contact our support team or check the Optimism documentation.